(this["webpackJsonp"] = this["webpackJsonp"] || []).push([
  ["passport-photo"],
  {
    1417: function (t, e, i) {
      (function (t) {
        /*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
        var n = n || { version: "2.7.0" };
        function r(t) {
          var e = t.targetCanvas,
            i = e.width,
            n = e.height,
            r = t.destinationWidth,
            s = t.destinationHeight;
          (i === r && n === s) || ((e.width = r), (e.height = s));
        }
        function s(t, e) {
          var i = t.canvas,
            n = e.targetCanvas,
            r = n.getContext("2d");
          r.translate(0, n.height), r.scale(1, -1);
          var s = i.height - n.height;
          r.drawImage(i, 0, s, n.width, n.height, 0, 0, n.width, n.height);
        }
        function o(t, e) {
          var i = e.targetCanvas,
            n = i.getContext("2d"),
            r = e.destinationWidth,
            s = e.destinationHeight,
            o = r * s * 4,
            a = new Uint8Array(this.imageBuffer, 0, o),
            h = new Uint8ClampedArray(this.imageBuffer, 0, o);
          t.readPixels(0, 0, r, s, t.RGBA, t.UNSIGNED_BYTE, a);
          var c = new ImageData(h, r, s);
          n.putImageData(c, 0, 0);
        }
        (e.fabric = n),
          "undefined" !== typeof document && "undefined" !== typeof window
            ? (document instanceof HTMLDocument
                ? (n.document = document)
                : (n.document = document.implementation.createHTMLDocument("")),
              (n.window = window))
            : ((n.document = i(1407).jsdom(
                decodeURIComponent(
                  "%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"
                ),
                { features: { FetchExternalResources: ["img"] } }
              )),
              (n.jsdomImplForWrapper = i(1408).implForWrapper),
              (n.nodeCanvas = i(1409).Canvas),
              (n.window = n.document.defaultView),
              (DOMParser = i(1410).DOMParser)),
          (n.isTouchSupported =
            "ontouchstart" in n.window ||
            "ontouchstart" in n.document ||
            (n.window && n.window.navigator && n.window.navigator.maxTouchPoints > 0)),
          (n.isLikelyNode = "undefined" !== typeof t && "undefined" === typeof window),
          (n.SHARED_ATTRIBUTES = [
            "display",
            "transform",
            "fill",
            "fill-opacity",
            "fill-rule",
            "opacity",
            "stroke",
            "stroke-dasharray",
            "stroke-linecap",
            "stroke-dashoffset",
            "stroke-linejoin",
            "stroke-miterlimit",
            "stroke-opacity",
            "stroke-width",
            "id",
            "paint-order",
            "vector-effect",
            "instantiated_by_use",
            "clip-path",
          ]),
          (n.DPI = 96),
          (n.reNum = "(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)"),
          (n.fontPaths = {}),
          (n.iMatrix = [1, 0, 0, 1, 0, 0]),
          (n.canvasModule = "canvas"),
          (n.perfLimitSizeTotal = 2097152),
          (n.maxCacheSideLimit = 4096),
          (n.minCacheSideLimit = 256),
          (n.charWidthsCache = {}),
          (n.textureSize = 2048),
          (n.enableGLFiltering = !0),
          (n.devicePixelRatio =
            n.window.devicePixelRatio ||
            n.window.webkitDevicePixelRatio ||
            n.window.mozDevicePixelRatio ||
            1),
          (n.browserShadowBlurConstant = 1),
          (n.arcToSegmentsCache = {}),
          (n.boundsOfCurveCache = {}),
          (n.cachesBoundsOfCurve = !0),
          (n.initFilterBackend = function () {
            return n.enableGLFiltering && n.isWebglSupported && n.isWebglSupported(n.textureSize)
              ? (console.log("max texture size: " + n.maxTextureSize),
                new n.WebglFilterBackend({ tileSize: n.textureSize }))
              : n.Canvas2dFilterBackend
              ? new n.Canvas2dFilterBackend()
              : void 0;
          }),
          "undefined" !== typeof document && "undefined" !== typeof window && (window.fabric = n),
          (function () {
            function t(t, e) {
              if (this.__eventListeners[t]) {
                var i = this.__eventListeners[t];
                e ? (i[i.indexOf(e)] = !1) : n.util.array.fill(i, !1);
              }
            }
            function e(t, e) {
              if ((this.__eventListeners || (this.__eventListeners = {}), 1 === arguments.length))
                for (var i in t) this.on(i, t[i]);
              else
                this.__eventListeners[t] || (this.__eventListeners[t] = []),
                  this.__eventListeners[t].push(e);
              return this;
            }
            function i(e, i) {
              if (this.__eventListeners) {
                if (0 === arguments.length) for (e in this.__eventListeners) t.call(this, e);
                else if (1 === arguments.length && "object" === typeof arguments[0])
                  for (var n in e) t.call(this, n, e[n]);
                else t.call(this, e, i);
                return this;
              }
            }
            function r(t, e) {
              if (this.__eventListeners) {
                var i = this.__eventListeners[t];
                if (i) {
                  for (var n = 0, r = i.length; n < r; n++) i[n] && i[n].call(this, e || {});
                  return (
                    (this.__eventListeners[t] = i.filter(function (t) {
                      return !1 !== t;
                    })),
                    this
                  );
                }
              }
            }
            n.Observable = { observe: e, stopObserving: i, fire: r, on: e, off: i, trigger: r };
          })(),
          (n.Collection = {
            _objects: [],
            add: function () {
              if ((this._objects.push.apply(this._objects, arguments), this._onObjectAdded))
                for (var t = 0, e = arguments.length; t < e; t++) this._onObjectAdded(arguments[t]);
              return this.renderOnAddRemove && this.requestRenderAll(), this;
            },
            insertAt: function (t, e, i) {
              var n = this._objects;
              return (
                i ? (n[e] = t) : n.splice(e, 0, t),
                this._onObjectAdded && this._onObjectAdded(t),
                this.renderOnAddRemove && this.requestRenderAll(),
                this
              );
            },
            remove: function () {
              for (var t, e = this._objects, i = !1, n = 0, r = arguments.length; n < r; n++)
                (t = e.indexOf(arguments[n])),
                  -1 !== t &&
                    ((i = !0),
                    e.splice(t, 1),
                    this._onObjectRemoved && this._onObjectRemoved(arguments[n]));
              return this.renderOnAddRemove && i && this.requestRenderAll(), this;
            },
            forEachObject: function (t, e) {
              for (var i = this.getObjects(), n = 0, r = i.length; n < r; n++)
                t.call(e, i[n], n, i);
              return this;
            },
            getObjects: function (t) {
              return "undefined" === typeof t
                ? this._objects.concat()
                : this._objects.filter(function (e) {
                    return e.type === t;
                  });
            },
            item: function (t) {
              return this._objects[t];
            },
            isEmpty: function () {
              return 0 === this._objects.length;
            },
            size: function () {
              return this._objects.length;
            },
            contains: function (t) {
              return this._objects.indexOf(t) > -1;
            },
            complexity: function () {
              return this._objects.reduce(function (t, e) {
                return (t += e.complexity ? e.complexity() : 0), t;
              }, 0);
            },
          }),
          (n.CommonMethods = {
            _setOptions: function (t) {
              for (var e in t) this.set(e, t[e]);
            },
            _initGradient: function (t, e) {
              !t || !t.colorStops || t instanceof n.Gradient || this.set(e, new n.Gradient(t));
            },
            _initPattern: function (t, e, i) {
              !t || !t.source || t instanceof n.Pattern
                ? i && i()
                : this.set(e, new n.Pattern(t, i));
            },
            _initClipping: function (t) {
              if (t.clipTo && "string" === typeof t.clipTo) {
                var e = n.util.getFunctionBody(t.clipTo);
                "undefined" !== typeof e && (this.clipTo = new Function("ctx", e));
              }
            },
            _setObject: function (t) {
              for (var e in t) this._set(e, t[e]);
            },
            set: function (t, e) {
              return (
                "object" === typeof t
                  ? this._setObject(t)
                  : "function" === typeof e && "clipTo" !== t
                  ? this._set(t, e(this.get(t)))
                  : this._set(t, e),
                this
              );
            },
            _set: function (t, e) {
              this[t] = e;
            },
            toggle: function (t) {
              var e = this.get(t);
              return "boolean" === typeof e && this.set(t, !e), this;
            },
            get: function (t) {
              return this[t];
            },
          }),
          (function (t) {
            var e = Math.sqrt,
              i = Math.atan2,
              r = Math.pow,
              s = Math.abs,
              o = Math.PI / 180,
              a = Math.PI / 2;
            n.util = {
              cos: function (t) {
                if (0 === t) return 1;
                t < 0 && (t = -t);
                var e = t / a;
                switch (e) {
                  case 1:
                  case 3:
                    return 0;
                  case 2:
                    return -1;
                }
                return Math.cos(t);
              },
              sin: function (t) {
                if (0 === t) return 0;
                var e = t / a,
                  i = 1;
                switch ((t < 0 && (i = -1), e)) {
                  case 1:
                    return i;
                  case 2:
                    return 0;
                  case 3:
                    return -i;
                }
                return Math.sin(t);
              },
              removeFromArray: function (t, e) {
                var i = t.indexOf(e);
                return -1 !== i && t.splice(i, 1), t;
              },
              getRandomInt: function (t, e) {
                return Math.floor(Math.random() * (e - t + 1)) + t;
              },
              degreesToRadians: function (t) {
                return t * o;
              },
              radiansToDegrees: function (t) {
                return t / o;
              },
              rotatePoint: function (t, e, i) {
                t.subtractEquals(e);
                var r = n.util.rotateVector(t, i);
                return new n.Point(r.x, r.y).addEquals(e);
              },
              rotateVector: function (t, e) {
                var i = n.util.sin(e),
                  r = n.util.cos(e),
                  s = t.x * r - t.y * i,
                  o = t.x * i + t.y * r;
                return { x: s, y: o };
              },
              transformPoint: function (t, e, i) {
                return i
                  ? new n.Point(e[0] * t.x + e[2] * t.y, e[1] * t.x + e[3] * t.y)
                  : new n.Point(e[0] * t.x + e[2] * t.y + e[4], e[1] * t.x + e[3] * t.y + e[5]);
              },
              makeBoundingBoxFromPoints: function (t) {
                var e = [t[0].x, t[1].x, t[2].x, t[3].x],
                  i = n.util.array.min(e),
                  r = n.util.array.max(e),
                  s = r - i,
                  o = [t[0].y, t[1].y, t[2].y, t[3].y],
                  a = n.util.array.min(o),
                  h = n.util.array.max(o),
                  c = h - a;
                return { left: i, top: a, width: s, height: c };
              },
              invertTransform: function (t) {
                var e = 1 / (t[0] * t[3] - t[1] * t[2]),
                  i = [e * t[3], -e * t[1], -e * t[2], e * t[0]],
                  r = n.util.transformPoint({ x: t[4], y: t[5] }, i, !0);
                return (i[4] = -r.x), (i[5] = -r.y), i;
              },
              toFixed: function (t, e) {
                return parseFloat(Number(t).toFixed(e));
              },
              parseUnit: function (t, e) {
                var i = /\D{0,2}$/.exec(t),
                  r = parseFloat(t);
                switch ((e || (e = n.Text.DEFAULT_SVG_FONT_SIZE), i[0])) {
                  case "mm":
                    return (r * n.DPI) / 25.4;
                  case "cm":
                    return (r * n.DPI) / 2.54;
                  case "in":
                    return r * n.DPI;
                  case "pt":
                    return (r * n.DPI) / 72;
                  case "pc":
                    return ((r * n.DPI) / 72) * 12;
                  case "em":
                    return r * e;
                  default:
                    return r;
                }
              },
              falseFunction: function () {
                return !1;
              },
              getKlass: function (t, e) {
                return (
                  (t = n.util.string.camelize(t.charAt(0).toUpperCase() + t.slice(1))),
                  n.util.resolveNamespace(e)[t]
                );
              },
              getSvgAttributes: function (t) {
                var e = ["instantiated_by_use", "style", "id", "class"];
                switch (t) {
                  case "linearGradient":
                    e = e.concat(["x1", "y1", "x2", "y2", "gradientUnits", "gradientTransform"]);
                    break;
                  case "radialGradient":
                    e = e.concat([
                      "gradientUnits",
                      "gradientTransform",
                      "cx",
                      "cy",
                      "r",
                      "fx",
                      "fy",
                      "fr",
                    ]);
                    break;
                  case "stop":
                    e = e.concat(["offset", "stop-color", "stop-opacity"]);
                    break;
                }
                return e;
              },
              resolveNamespace: function (e) {
                if (!e) return n;
                var i,
                  r = e.split("."),
                  s = r.length,
                  o = t || n.window;
                for (i = 0; i < s; ++i) o = o[r[i]];
                return o;
              },
              loadImage: function (t, e, i, r) {
                if (t) {
                  var s = n.util.createImage(),
                    o = function () {
                      e && e.call(i, s), (s = s.onload = s.onerror = null);
                    };
                  (s.onload = o),
                    (s.onerror = function () {
                      n.log("Error loading " + s.src),
                        e && e.call(i, null, !0),
                        (s = s.onload = s.onerror = null);
                    }),
                    0 !== t.indexOf("data") && r && (s.crossOrigin = r),
                    "data:image/svg" === t.substring(0, 14) &&
                      ((s.onload = null), n.util.loadImageInDom(s, o)),
                    (s.src = t);
                } else e && e.call(i, t);
              },
              loadImageInDom: function (t, e) {
                var i = n.document.createElement("div");
                (i.style.width = i.style.height = "1px"),
                  (i.style.left = i.style.top = "-100%"),
                  (i.style.position = "absolute"),
                  i.appendChild(t),
                  n.document.querySelector("body").appendChild(i),
                  (t.onload = function () {
                    e(), i.parentNode.removeChild(i), (i = null);
                  });
              },
              enlivenObjects: function (t, e, i, r) {
                function s() {
                  ++a === h && e && e(o);
                }
                t = t || [];
                var o = [],
                  a = 0,
                  h = t.length;
                h
                  ? t.forEach(function (t, e) {
                      if (t && t.type) {
                        var a = n.util.getKlass(t.type, i);
                        a.fromObject(t, function (i, n) {
                          n || (o[e] = i), r && r(t, i, n), s();
                        });
                      } else s();
                    })
                  : e && e(o);
              },
              enlivenPatterns: function (t, e) {
                function i() {
                  ++s === o && e && e(r);
                }
                t = t || [];
                var r = [],
                  s = 0,
                  o = t.length;
                o
                  ? t.forEach(function (t, e) {
                      t && t.source
                        ? new n.Pattern(t, function (t) {
                            (r[e] = t), i();
                          })
                        : ((r[e] = t), i());
                    })
                  : e && e(r);
              },
              groupSVGElements: function (t, e, i) {
                var r;
                return t && 1 === t.length
                  ? t[0]
                  : (e &&
                      (e.width && e.height
                        ? (e.centerPoint = { x: e.width / 2, y: e.height / 2 })
                        : (delete e.width, delete e.height)),
                    (r = new n.Group(t, e)),
                    "undefined" !== typeof i && (r.sourcePath = i),
                    r);
              },
              populateWithProperties: function (t, e, i) {
                if (i && "[object Array]" === Object.prototype.toString.call(i))
                  for (var n = 0, r = i.length; n < r; n++) i[n] in t && (e[i[n]] = t[i[n]]);
              },
              drawDashedLine: function (t, n, r, s, o, a) {
                var h = s - n,
                  c = o - r,
                  l = e(h * h + c * c),
                  u = i(c, h),
                  f = a.length,
                  d = 0,
                  g = !0;
                t.save(), t.translate(n, r), t.moveTo(0, 0), t.rotate(u), (n = 0);
                while (l > n)
                  (n += a[d++ % f]), n > l && (n = l), t[g ? "lineTo" : "moveTo"](n, 0), (g = !g);
                t.restore();
              },
              createCanvasElement: function () {
                return n.document.createElement("canvas");
              },
              copyCanvasElement: function (t) {
                var e = n.util.createCanvasElement();
                return (
                  (e.width = t.width),
                  (e.height = t.height),
                  e.getContext("2d").drawImage(t, 0, 0),
                  e
                );
              },
              toDataURL: function (t, e, i) {
                return t.toDataURL("image/" + e, i);
              },
              createImage: function () {
                return n.document.createElement("img");
              },
              clipContext: function (t, e) {
                e.save(), e.beginPath(), t.clipTo(e), e.clip();
              },
              multiplyTransformMatrices: function (t, e, i) {
                return [
                  t[0] * e[0] + t[2] * e[1],
                  t[1] * e[0] + t[3] * e[1],
                  t[0] * e[2] + t[2] * e[3],
                  t[1] * e[2] + t[3] * e[3],
                  i ? 0 : t[0] * e[4] + t[2] * e[5] + t[4],
                  i ? 0 : t[1] * e[4] + t[3] * e[5] + t[5],
                ];
              },
              qrDecompose: function (t) {
                var n = i(t[1], t[0]),
                  s = r(t[0], 2) + r(t[1], 2),
                  a = e(s),
                  h = (t[0] * t[3] - t[2] * t[1]) / a,
                  c = i(t[0] * t[2] + t[1] * t[3], s);
                return {
                  angle: n / o,
                  scaleX: a,
                  scaleY: h,
                  skewX: c / o,
                  skewY: 0,
                  translateX: t[4],
                  translateY: t[5],
                };
              },
              customTransformMatrix: function (t, e, i) {
                var r = [1, 0, s(Math.tan(i * o)), 1],
                  a = [s(t), 0, 0, s(e)];
                return n.util.multiplyTransformMatrices(a, r, !0);
              },
              resetObjectTransform: function (t) {
                (t.scaleX = 1),
                  (t.scaleY = 1),
                  (t.skewX = 0),
                  (t.skewY = 0),
                  (t.flipX = !1),
                  (t.flipY = !1),
                  t.rotate(0);
              },
              saveObjectTransform: function (t) {
                return {
                  scaleX: t.scaleX,
                  scaleY: t.scaleY,
                  skewX: t.skewX,
                  skewY: t.skewY,
                  angle: t.angle,
                  left: t.left,
                  flipX: t.flipX,
                  flipY: t.flipY,
                  top: t.top,
                };
              },
              getFunctionBody: function (t) {
                return (String(t).match(/function[^{]*\{([\s\S]*)\}/) || {})[1];
              },
              isTransparent: function (t, e, i, n) {
                n > 0 && (e > n ? (e -= n) : (e = 0), i > n ? (i -= n) : (i = 0));
                var r,
                  s,
                  o = !0,
                  a = t.getImageData(e, i, 2 * n || 1, 2 * n || 1),
                  h = a.data.length;
                for (r = 3; r < h; r += 4) if (((s = a.data[r]), (o = s <= 0), !1 === o)) break;
                return (a = null), o;
              },
              parsePreserveAspectRatioAttribute: function (t) {
                var e,
                  i = "meet",
                  n = "Mid",
                  r = "Mid",
                  s = t.split(" ");
                return (
                  s &&
                    s.length &&
                    ((i = s.pop()),
                    "meet" !== i && "slice" !== i
                      ? ((e = i), (i = "meet"))
                      : s.length && (e = s.pop())),
                  (n = "none" !== e ? e.slice(1, 4) : "none"),
                  (r = "none" !== e ? e.slice(5, 8) : "none"),
                  { meetOrSlice: i, alignX: n, alignY: r }
                );
              },
              clearFabricFontCache: function (t) {
                (t = (t || "").toLowerCase()),
                  t
                    ? n.charWidthsCache[t] && delete n.charWidthsCache[t]
                    : (n.charWidthsCache = {});
              },
              limitDimsByArea: function (t, e) {
                var i = Math.sqrt(e * t),
                  n = Math.floor(e / i);
                return { x: Math.floor(i), y: n };
              },
              capValue: function (t, e, i) {
                return Math.max(t, Math.min(e, i));
              },
              findScaleToFit: function (t, e) {
                return Math.min(e.width / t.width, e.height / t.height);
              },
              findScaleToCover: function (t, e) {
                return Math.max(e.width / t.width, e.height / t.height);
              },
            };
          })(e),
          (function () {
            var t = Array.prototype.join;
            function e(e, s, o, a, h, c, l) {
              var u = t.call(arguments);
              if (n.arcToSegmentsCache[u]) return n.arcToSegmentsCache[u];
              var f = Math.PI,
                d = (l * f) / 180,
                g = n.util.sin(d),
                p = n.util.cos(d),
                m = 0,
                v = 0;
              (o = Math.abs(o)), (a = Math.abs(a));
              var _ = -p * e * 0.5 - g * s * 0.5,
                y = -p * s * 0.5 + g * e * 0.5,
                b = o * o,
                x = a * a,
                C = y * y,
                w = _ * _,
                S = b * x - b * C - x * w,
                T = 0;
              if (S < 0) {
                var O = Math.sqrt(1 - S / (b * x));
                (o *= O), (a *= O);
              } else T = (h === c ? -1 : 1) * Math.sqrt(S / (b * C + x * w));
              var k = (T * o * y) / a,
                E = (-T * a * _) / o,
                P = p * k - g * E + 0.5 * e,
                D = g * k + p * E + 0.5 * s,
                j = r(1, 0, (_ - k) / o, (y - E) / a),
                A = r((_ - k) / o, (y - E) / a, (-_ - k) / o, (-y - E) / a);
              0 === c && A > 0 ? (A -= 2 * f) : 1 === c && A < 0 && (A += 2 * f);
              for (
                var M = Math.ceil(Math.abs((A / f) * 2)),
                  I = [],
                  F = A / M,
                  R = ((8 / 3) * Math.sin(F / 4) * Math.sin(F / 4)) / Math.sin(F / 2),
                  L = j + F,
                  B = 0;
                B < M;
                B++
              )
                (I[B] = i(j, L, p, g, o, a, P, D, R, m, v)),
                  (m = I[B][4]),
                  (v = I[B][5]),
                  (j = L),
                  (L += F);
              return (n.arcToSegmentsCache[u] = I), I;
            }
            function i(t, e, i, r, s, o, a, h, c, l, u) {
              var f = n.util.cos(t),
                d = n.util.sin(t),
                g = n.util.cos(e),
                p = n.util.sin(e),
                m = i * s * g - r * o * p + a,
                v = r * s * g + i * o * p + h,
                _ = l + c * (-i * s * d - r * o * f),
                y = u + c * (-r * s * d + i * o * f),
                b = m + c * (i * s * p + r * o * g),
                x = v + c * (r * s * p - i * o * g);
              return [_, y, b, x, m, v];
            }
            function r(t, e, i, n) {
              var r = Math.atan2(e, t),
                s = Math.atan2(n, i);
              return s >= r ? s - r : 2 * Math.PI - (r - s);
            }
            function s(e, i, r, s, o, a, h, c) {
              var l;
              if (n.cachesBoundsOfCurve && ((l = t.call(arguments)), n.boundsOfCurveCache[l]))
                return n.boundsOfCurveCache[l];
              var u,
                f,
                d,
                g,
                p,
                m,
                v,
                _,
                y = Math.sqrt,
                b = Math.min,
                x = Math.max,
                C = Math.abs,
                w = [],
                S = [[], []];
              (f = 6 * e - 12 * r + 6 * o),
                (u = -3 * e + 9 * r - 9 * o + 3 * h),
                (d = 3 * r - 3 * e);
              for (var T = 0; T < 2; ++T)
                if (
                  (T > 0 &&
                    ((f = 6 * i - 12 * s + 6 * a),
                    (u = -3 * i + 9 * s - 9 * a + 3 * c),
                    (d = 3 * s - 3 * i)),
                  C(u) < 1e-12)
                ) {
                  if (C(f) < 1e-12) continue;
                  (g = -d / f), 0 < g && g < 1 && w.push(g);
                } else
                  (v = f * f - 4 * d * u),
                    v < 0 ||
                      ((_ = y(v)),
                      (p = (-f + _) / (2 * u)),
                      0 < p && p < 1 && w.push(p),
                      (m = (-f - _) / (2 * u)),
                      0 < m && m < 1 && w.push(m));
              var O,
                k,
                E,
                P = w.length,
                D = P;
              while (P--)
                (g = w[P]),
                  (E = 1 - g),
                  (O = E * E * E * e + 3 * E * E * g * r + 3 * E * g * g * o + g * g * g * h),
                  (S[0][P] = O),
                  (k = E * E * E * i + 3 * E * E * g * s + 3 * E * g * g * a + g * g * g * c),
                  (S[1][P] = k);
              (S[0][D] = e), (S[1][D] = i), (S[0][D + 1] = h), (S[1][D + 1] = c);
              var j = [
                { x: b.apply(null, S[0]), y: b.apply(null, S[1]) },
                { x: x.apply(null, S[0]), y: x.apply(null, S[1]) },
              ];
              return n.cachesBoundsOfCurve && (n.boundsOfCurveCache[l] = j), j;
            }
            (n.util.drawArc = function (t, i, n, r) {
              for (
                var s = r[0],
                  o = r[1],
                  a = r[2],
                  h = r[3],
                  c = r[4],
                  l = r[5],
                  u = r[6],
                  f = [[], [], [], []],
                  d = e(l - i, u - n, s, o, h, c, a),
                  g = 0,
                  p = d.length;
                g < p;
                g++
              )
                (f[g][0] = d[g][0] + i),
                  (f[g][1] = d[g][1] + n),
                  (f[g][2] = d[g][2] + i),
                  (f[g][3] = d[g][3] + n),
                  (f[g][4] = d[g][4] + i),
                  (f[g][5] = d[g][5] + n),
                  t.bezierCurveTo.apply(t, f[g]);
            }),
              (n.util.getBoundsOfArc = function (t, i, n, r, o, a, h, c, l) {
                for (
                  var u,
                    f = 0,
                    d = 0,
                    g = [],
                    p = e(c - t, l - i, n, r, a, h, o),
                    m = 0,
                    v = p.length;
                  m < v;
                  m++
                )
                  (u = s(f, d, p[m][0], p[m][1], p[m][2], p[m][3], p[m][4], p[m][5])),
                    g.push({ x: u[0].x + t, y: u[0].y + i }),
                    g.push({ x: u[1].x + t, y: u[1].y + i }),
                    (f = p[m][4]),
                    (d = p[m][5]);
                return g;
              }),
              (n.util.getBoundsOfCurve = s);
          })(),
          (function () {
            var t = Array.prototype.slice;
            function e(e, i) {
              for (var n = t.call(arguments, 2), r = [], s = 0, o = e.length; s < o; s++)
                r[s] = n.length ? e[s][i].apply(e[s], n) : e[s][i].call(e[s]);
              return r;
            }
            function i(t, e) {
              return o(t, e, function (t, e) {
                return t >= e;
              });
            }
            function r(t, e) {
              return o(t, e, function (t, e) {
                return t < e;
              });
            }
            function s(t, e) {
              var i = t.length;
              while (i--) t[i] = e;
              return t;
            }
            function o(t, e, i) {
              if (t && 0 !== t.length) {
                var n = t.length - 1,
                  r = e ? t[n][e] : t[n];
                if (e) while (n--) i(t[n][e], r) && (r = t[n][e]);
                else while (n--) i(t[n], r) && (r = t[n]);
                return r;
              }
            }
            n.util.array = { fill: s, invoke: e, min: r, max: i };
          })(),
          (function () {
            function t(e, i, r) {
              if (r)
                if (!n.isLikelyNode && i instanceof Element) e = i;
                else if (i instanceof Array) {
                  e = [];
                  for (var s = 0, o = i.length; s < o; s++) e[s] = t({}, i[s], r);
                } else if (i && "object" === typeof i)
                  for (var a in i)
                    "canvas" === a
                      ? (e[a] = t({}, i[a]))
                      : i.hasOwnProperty(a) && (e[a] = t({}, i[a], r));
                else e = i;
              else for (var a in i) e[a] = i[a];
              return e;
            }
            function e(e, i) {
              return t({}, e, i);
            }
            (n.util.object = { extend: t, clone: e }), n.util.object.extend(n.util, n.Observable);
          })(),
          (function () {
            function t(t) {
              return t.replace(/-+(.)?/g, function (t, e) {
                return e ? e.toUpperCase() : "";
              });
            }
            function e(t, e) {
              return t.charAt(0).toUpperCase() + (e ? t.slice(1) : t.slice(1).toLowerCase());
            }
            function i(t) {
              return t
                .replace(/&/g, "&amp;")
                .replace(/"/g, "&quot;")
                .replace(/'/g, "&apos;")
                .replace(/</g, "&lt;")
                .replace(/>/g, "&gt;");
            }
            function r(t) {
              var e,
                i = 0,
                n = [];
              for (i = 0, e; i < t.length; i++) !1 !== (e = s(t, i)) && n.push(e);
              return n;
            }
            function s(t, e) {
              var i = t.charCodeAt(e);
              if (isNaN(i)) return "";
              if (i < 55296 || i > 57343) return t.charAt(e);
              if (55296 <= i && i <= 56319) {
                if (t.length <= e + 1) throw "High surrogate without following low surrogate";
                var n = t.charCodeAt(e + 1);
                if (56320 > n || n > 57343) throw "High surrogate without following low surrogate";
                return t.charAt(e) + t.charAt(e + 1);
              }
              if (0 === e) throw "Low surrogate without preceding high surrogate";
              var r = t.charCodeAt(e - 1);
              if (55296 > r || r > 56319) throw "Low surrogate without preceding high surrogate";
              return !1;
            }
            n.util.string = { camelize: t, capitalize: e, escapeXml: i, graphemeSplit: r };
          })(),
          (function () {
            var t = Array.prototype.slice,
              e = function () {},
              i = (function () {
                for (var t in { toString: 1 }) if ("toString" === t) return !1;
                return !0;
              })(),
              r = function (t, e, n) {
                for (var r in e)
                  r in t.prototype &&
                  "function" === typeof t.prototype[r] &&
                  (e[r] + "").indexOf("callSuper") > -1
                    ? (t.prototype[r] = (function (t) {
                        return function () {
                          var i = this.constructor.superclass;
                          this.constructor.superclass = n;
                          var r = e[t].apply(this, arguments);
                          if (((this.constructor.superclass = i), "initialize" !== t)) return r;
                        };
                      })(r))
                    : (t.prototype[r] = e[r]),
                    i &&
                      (e.toString !== Object.prototype.toString &&
                        (t.prototype.toString = e.toString),
                      e.valueOf !== Object.prototype.valueOf && (t.prototype.valueOf = e.valueOf));
              };
            function s() {}
            function o(e) {
              var i = null,
                n = this;
              while (n.constructor.superclass) {
                var r = n.constructor.superclass.prototype[e];
                if (n[e] !== r) {
                  i = r;
                  break;
                }
                n = n.constructor.superclass.prototype;
              }
              return i
                ? arguments.length > 1
                  ? i.apply(this, t.call(arguments, 1))
                  : i.call(this)
                : console.log(
                    "tried to callSuper " + e + ", method not found in prototype chain",
                    this
                  );
            }
            function a() {
              var i = null,
                n = t.call(arguments, 0);
              function a() {
                this.initialize.apply(this, arguments);
              }
              "function" === typeof n[0] && (i = n.shift()),
                (a.superclass = i),
                (a.subclasses = []),
                i && ((s.prototype = i.prototype), (a.prototype = new s()), i.subclasses.push(a));
              for (var h = 0, c = n.length; h < c; h++) r(a, n[h], i);
              return (
                a.prototype.initialize || (a.prototype.initialize = e),
                (a.prototype.constructor = a),
                (a.prototype.callSuper = o),
                a
              );
            }
            n.util.createClass = a;
          })(),
          (function () {
            var t = "unknown";
            function e(t) {
              var e,
                i,
                n = Array.prototype.slice.call(arguments, 1),
                r = n.length;
              for (i = 0; i < r; i++)
                if (((e = typeof t[n[i]]), !/^(?:function|object|unknown)$/.test(e))) return !1;
              return !0;
            }
            var i,
              r,
              s = (function () {
                var t = 0;
                return function (e) {
                  return e.__uniqueID || (e.__uniqueID = "uniqueID__" + t++);
                };
              })();
            function o(t, e) {
              return { handler: e, wrappedHandler: a(t, e) };
            }
            function a(t, e) {
              return function (r) {
                e.call(i(t), r || n.window.event);
              };
            }
            function h(t, e) {
              return function (i) {
                if (g[t] && g[t][e])
                  for (var r = g[t][e], s = 0, o = r.length; s < o; s++)
                    r[s].call(this, i || n.window.event);
              };
            }
            (function () {
              var t = {};
              (i = function (e) {
                return t[e];
              }),
                (r = function (e, i) {
                  t[e] = i;
                });
            })();
            var c,
              l,
              u =
                e(n.document.documentElement, "addEventListener", "removeEventListener") &&
                e(n.window, "addEventListener", "removeEventListener"),
              f =
                e(n.document.documentElement, "attachEvent", "detachEvent") &&
                e(n.window, "attachEvent", "detachEvent"),
              d = {},
              g = {};
            function p(e) {
              e || (e = n.window.event);
              var i = e.target || (typeof e.srcElement !== t ? e.srcElement : null),
                r = n.util.getScrollLeftTop(i);
              return { x: m(e) + r.left, y: v(e) + r.top };
            }
            u
              ? ((c = function (t, e, i, n) {
                  t && t.addEventListener(e, i, !f && n);
                }),
                (l = function (t, e, i, n) {
                  t && t.removeEventListener(e, i, !f && n);
                }))
              : f
              ? ((c = function (t, e, i) {
                  if (t) {
                    var n = s(t);
                    r(n, t), d[n] || (d[n] = {}), d[n][e] || (d[n][e] = []);
                    var a = o(n, i);
                    d[n][e].push(a), t.attachEvent("on" + e, a.wrappedHandler);
                  }
                }),
                (l = function (t, e, i) {
                  if (t) {
                    var n,
                      r = s(t);
                    if (d[r] && d[r][e])
                      for (var o = 0, a = d[r][e].length; o < a; o++)
                        (n = d[r][e][o]),
                          n &&
                            n.handler === i &&
                            (t.detachEvent("on" + e, n.wrappedHandler), (d[r][e][o] = null));
                  }
                }))
              : ((c = function (t, e, i) {
                  if (t) {
                    var n = s(t);
                    if ((g[n] || (g[n] = {}), !g[n][e])) {
                      g[n][e] = [];
                      var r = t["on" + e];
                      r && g[n][e].push(r), (t["on" + e] = h(n, e));
                    }
                    g[n][e].push(i);
                  }
                }),
                (l = function (t, e, i) {
                  if (t) {
                    var n = s(t);
                    if (g[n] && g[n][e])
                      for (var r = g[n][e], o = 0, a = r.length; o < a; o++)
                        r[o] === i && r.splice(o, 1);
                  }
                })),
              (n.util.addListener = c),
              (n.util.removeListener = l);
            var m = function (t) {
                return t.clientX;
              },
              v = function (t) {
                return t.clientY;
              };
            function _(t, e, i) {
              var n,
                r = "touchend" === t.type ? "changedTouches" : "touches",
                s = t[r];
              return s && s[0] && (n = s[0][i]), "undefined" === typeof n && (n = t[i]), n;
            }
            n.isTouchSupported &&
              ((m = function (t) {
                return _(t, "pageX", "clientX");
              }),
              (v = function (t) {
                return _(t, "pageY", "clientY");
              })),
              (n.util.getPointer = p);
          })(),
          (function () {
            function t(t, e) {
              var i = t.style;
              if (!i) return t;
              if ("string" === typeof e)
                return (
                  (t.style.cssText += ";" + e),
                  e.indexOf("opacity") > -1 ? o(t, e.match(/opacity:\s*(\d?\.?\d*)/)[1]) : t
                );
              for (var n in e)
                if ("opacity" === n) o(t, e[n]);
                else {
                  var r =
                    "float" === n || "cssFloat" === n
                      ? "undefined" === typeof i.styleFloat
                        ? "cssFloat"
                        : "styleFloat"
                      : n;
                  i[r] = e[n];
                }
              return t;
            }
            var e = n.document.createElement("div"),
              i = "string" === typeof e.style.opacity,
              r = "string" === typeof e.style.filter,
              s = /alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,
              o = function (t) {
                return t;
              };
            i
              ? (o = function (t, e) {
                  return (t.style.opacity = e), t;
                })
              : r &&
                (o = function (t, e) {
                  var i = t.style;
                  return (
                    t.currentStyle && !t.currentStyle.hasLayout && (i.zoom = 1),
                    s.test(i.filter)
                      ? ((e = e >= 0.9999 ? "" : "alpha(opacity=" + 100 * e + ")"),
                        (i.filter = i.filter.replace(s, e)))
                      : (i.filter += " alpha(opacity=" + 100 * e + ")"),
                    t
                  );
                }),
              (n.util.setStyle = t);
          })(),
          (function () {
            var t = Array.prototype.slice;
            function e(t) {
              return "string" === typeof t ? n.document.getElementById(t) : t;
            }
            var i,
              r,
              s = function (e) {
                return t.call(e, 0);
              };
            try {
              i = s(n.document.childNodes) instanceof Array;
            } catch (d) {}
            function o(t, e) {
              var i = n.document.createElement(t);
              for (var r in e)
                "class" === r
                  ? (i.className = e[r])
                  : "for" === r
                  ? (i.htmlFor = e[r])
                  : i.setAttribute(r, e[r]);
              return i;
            }
            function a(t, e) {
              t &&
                -1 === (" " + t.className + " ").indexOf(" " + e + " ") &&
                (t.className += (t.className ? " " : "") + e);
            }
            function h(t, e, i) {
              return (
                "string" === typeof e && (e = o(e, i)),
                t.parentNode && t.parentNode.replaceChild(e, t),
                e.appendChild(t),
                e
              );
            }
            function c(t) {
              var e = 0,
                i = 0,
                r = n.document.documentElement,
                s = n.document.body || { scrollLeft: 0, scrollTop: 0 };
              while (t && (t.parentNode || t.host))
                if (
                  ((t = t.parentNode || t.host),
                  t === n.document
                    ? ((e = s.scrollLeft || r.scrollLeft || 0),
                      (i = s.scrollTop || r.scrollTop || 0))
                    : ((e += t.scrollLeft || 0), (i += t.scrollTop || 0)),
                  1 === t.nodeType && "fixed" === t.style.position)
                )
                  break;
              return { left: e, top: i };
            }
            function l(t) {
              var e,
                i,
                n = t && t.ownerDocument,
                s = { left: 0, top: 0 },
                o = { left: 0, top: 0 },
                a = {
                  borderLeftWidth: "left",
                  borderTopWidth: "top",
                  paddingLeft: "left",
                  paddingTop: "top",
                };
              if (!n) return o;
              for (var h in a) o[a[h]] += parseInt(r(t, h), 10) || 0;
              return (
                (e = n.documentElement),
                "undefined" !== typeof t.getBoundingClientRect && (s = t.getBoundingClientRect()),
                (i = c(t)),
                {
                  left: s.left + i.left - (e.clientLeft || 0) + o.left,
                  top: s.top + i.top - (e.clientTop || 0) + o.top,
                }
              );
            }
            function u(t) {
              var e = n.jsdomImplForWrapper(t);
              return e._canvas || e._image;
            }
            function f(t) {
              if (n.isLikelyNode) {
                var e = n.jsdomImplForWrapper(t);
                e &&
                  ((e._image = null),
                  (e._canvas = null),
                  (e._currentSrc = null),
                  (e._attributes = null),
                  (e._classList = null));
              }
            }
            i ||
              (s = function (t) {
                var e = new Array(t.length),
                  i = t.length;
                while (i--) e[i] = t[i];
                return e;
              }),
              (r =
                n.document.defaultView && n.document.defaultView.getComputedStyle
                  ? function (t, e) {
                      var i = n.document.defaultView.getComputedStyle(t, null);
                      return i ? i[e] : void 0;
                    }
                  : function (t, e) {
                      var i = t.style[e];
                      return !i && t.currentStyle && (i = t.currentStyle[e]), i;
                    }),
              (function () {
                var t = n.document.documentElement.style,
                  e =
                    "userSelect" in t
                      ? "userSelect"
                      : "MozUserSelect" in t
                      ? "MozUserSelect"
                      : "WebkitUserSelect" in t
                      ? "WebkitUserSelect"
                      : "KhtmlUserSelect" in t
                      ? "KhtmlUserSelect"
                      : "";
                function i(t) {
                  return (
                    "undefined" !== typeof t.onselectstart &&
                      (t.onselectstart = n.util.falseFunction),
                    e
                      ? (t.style[e] = "none")
                      : "string" === typeof t.unselectable && (t.unselectable = "on"),
                    t
                  );
                }
                function r(t) {
                  return (
                    "undefined" !== typeof t.onselectstart && (t.onselectstart = null),
                    e
                      ? (t.style[e] = "")
                      : "string" === typeof t.unselectable && (t.unselectable = ""),
                    t
                  );
                }
                (n.util.makeElementUnselectable = i), (n.util.makeElementSelectable = r);
              })(),
              (function () {
                function t(t, e) {
                  var i = n.document.getElementsByTagName("head")[0],
                    r = n.document.createElement("script"),
                    s = !0;
                  (r.onload = r.onreadystatechange =
                    function (t) {
                      if (s) {
                        if (
                          "string" === typeof this.readyState &&
                          "loaded" !== this.readyState &&
                          "complete" !== this.readyState
                        )
                          return;
                        (s = !1),
                          e(t || n.window.event),
                          (r = r.onload = r.onreadystatechange = null);
                      }
                    }),
                    (r.src = t),
                    i.appendChild(r);
                }
                n.util.getScript = t;
              })(),
              (n.util.getById = e),
              (n.util.toArray = s),
              (n.util.makeElement = o),
              (n.util.addClass = a),
              (n.util.wrapElement = h),
              (n.util.getScrollLeftTop = c),
              (n.util.getElementOffset = l),
              (n.util.getElementStyle = r),
              (n.util.getNodeCanvas = u),
              (n.util.cleanUpJsdomNode = f);
          })(),
          (function () {
            function t(t, e) {
              return t + (/\?/.test(t) ? "&" : "?") + e;
            }
            function e() {}
            function i(i, r) {
              r || (r = {});
              var s = r.method ? r.method.toUpperCase() : "GET",
                o = r.onComplete || function () {},
                a = new n.window.XMLHttpRequest(),
                h = r.body || r.parameters;
              return (
                (a.onreadystatechange = function () {
                  4 === a.readyState && (o(a), (a.onreadystatechange = e));
                }),
                "GET" === s &&
                  ((h = null), "string" === typeof r.parameters && (i = t(i, r.parameters))),
                a.open(s, i, !0),
                ("POST" !== s && "PUT" !== s) ||
                  a.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"),
                a.send(h),
                a
              );
            }
            n.util.request = i;
          })(),
          (n.log = function () {}),
          (n.warn = function () {}),
          "undefined" !== typeof console &&
            ["log", "warn"].forEach(function (t) {
              "undefined" !== typeof console[t] &&
                "function" === typeof console[t].apply &&
                (n[t] = function () {
                  return console[t].apply(console, arguments);
                });
            }),
          (function () {
            function t() {
              return !1;
            }
            function e(e) {
              s(function (i) {
                e || (e = {});
                var n,
                  r = i || +new Date(),
                  o = e.duration || 500,
                  a = r + o,
                  h = e.onChange || t,
                  c = e.abort || t,
                  l = e.onComplete || t,
                  u =
                    e.easing ||
                    function (t, e, i, n) {
                      return -i * Math.cos((t / n) * (Math.PI / 2)) + i + e;
                    },
                  f = "startValue" in e ? e.startValue : 0,
                  d = "endValue" in e ? e.endValue : 100,
                  g = e.byValue || d - f;
                e.onStart && e.onStart(),
                  (function t(i) {
                    if (c()) l(d, 1, 1);
                    else {
                      n = i || +new Date();
                      var p = n > a ? o : n - r,
                        m = p / o,
                        v = u(p, f, g, o),
                        _ = Math.abs((v - f) / g);
                      h(v, _, m), n > a ? e.onComplete && e.onComplete() : s(t);
                    }
                  })(r);
              });
            }
            var i =
                n.window.requestAnimationFrame ||
                n.window.webkitRequestAnimationFrame ||
                n.window.mozRequestAnimationFrame ||
                n.window.oRequestAnimationFrame ||
                n.window.msRequestAnimationFrame ||
                function (t) {
                  return n.window.setTimeout(t, 1e3 / 60);
                },
              r = n.window.cancelAnimationFrame || n.window.clearTimeout;
            function s() {
              return i.apply(n.window, arguments);
            }
            function o() {
              return r.apply(n.window, arguments);
            }
            (n.util.animate = e), (n.util.requestAnimFrame = s), (n.util.cancelAnimFrame = o);
          })(),
          (function () {
            function t(t, e, i) {
              var n =
                "rgba(" +
                parseInt(t[0] + i * (e[0] - t[0]), 10) +
                "," +
                parseInt(t[1] + i * (e[1] - t[1]), 10) +
                "," +
                parseInt(t[2] + i * (e[2] - t[2]), 10);
              return (
                (n += "," + (t && e ? parseFloat(t[3] + i * (e[3] - t[3])) : 1)), (n += ")"), n
              );
            }
            function e(e, i, r, s) {
              var o = new n.Color(e).getSource(),
                a = new n.Color(i).getSource();
              (s = s || {}),
                n.util.animate(
                  n.util.object.extend(s, {
                    duration: r || 500,
                    startValue: o,
                    endValue: a,
                    byValue: a,
                    easing: function (e, i, n, r) {
                      var o = s.colorEasing
                        ? s.colorEasing(e, r)
                        : 1 - Math.cos((e / r) * (Math.PI / 2));
                      return t(i, n, o);
                    },
                  })
                );
            }
            n.util.animateColor = e;
          })(),
          (function () {
            function t(t, e, i, n) {
              return (
                t < Math.abs(e)
                  ? ((t = e), (n = i / 4))
                  : (n =
                      0 === e && 0 === t
                        ? (i / (2 * Math.PI)) * Math.asin(1)
                        : (i / (2 * Math.PI)) * Math.asin(e / t)),
                { a: t, c: e, p: i, s: n }
              );
            }
            function e(t, e, i) {
              return (
                t.a * Math.pow(2, 10 * (e -= 1)) * Math.sin(((e * i - t.s) * (2 * Math.PI)) / t.p)
              );
            }
            function i(t, e, i, n) {
              return i * ((t = t / n - 1) * t * t + 1) + e;
            }
            function r(t, e, i, n) {
              return (
                (t /= n / 2), t < 1 ? (i / 2) * t * t * t + e : (i / 2) * ((t -= 2) * t * t + 2) + e
              );
            }
            function s(t, e, i, n) {
              return i * (t /= n) * t * t * t + e;
            }
            function o(t, e, i, n) {
              return -i * ((t = t / n - 1) * t * t * t - 1) + e;
            }
            function a(t, e, i, n) {
              return (
                (t /= n / 2),
                t < 1 ? (i / 2) * t * t * t * t + e : (-i / 2) * ((t -= 2) * t * t * t - 2) + e
              );
            }
            function h(t, e, i, n) {
              return i * (t /= n) * t * t * t * t + e;
            }
            function c(t, e, i, n) {
              return i * ((t = t / n - 1) * t * t * t * t + 1) + e;
            }
            function l(t, e, i, n) {
              return (
                (t /= n / 2),
                t < 1
                  ? (i / 2) * t * t * t * t * t + e
                  : (i / 2) * ((t -= 2) * t * t * t * t + 2) + e
              );
            }
            function u(t, e, i, n) {
              return -i * Math.cos((t / n) * (Math.PI / 2)) + i + e;
            }
            function f(t, e, i, n) {
              return i * Math.sin((t / n) * (Math.PI / 2)) + e;
            }
            function d(t, e, i, n) {
              return (-i / 2) * (Math.cos((Math.PI * t) / n) - 1) + e;
            }
            function g(t, e, i, n) {
              return 0 === t ? e : i * Math.pow(2, 10 * (t / n - 1)) + e;
            }
            function p(t, e, i, n) {
              return t === n ? e + i : i * (1 - Math.pow(2, (-10 * t) / n)) + e;
            }
            function m(t, e, i, n) {
              return 0 === t
                ? e
                : t === n
                ? e + i
                : ((t /= n / 2),
                  t < 1
                    ? (i / 2) * Math.pow(2, 10 * (t - 1)) + e
                    : (i / 2) * (2 - Math.pow(2, -10 * --t)) + e);
            }
            function v(t, e, i, n) {
              return -i * (Math.sqrt(1 - (t /= n) * t) - 1) + e;
            }
            function _(t, e, i, n) {
              return i * Math.sqrt(1 - (t = t / n - 1) * t) + e;
            }
            function y(t, e, i, n) {
              return (
                (t /= n / 2),
                t < 1
                  ? (-i / 2) * (Math.sqrt(1 - t * t) - 1) + e
                  : (i / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + e
              );
            }
            function b(i, n, r, s) {
              var o = 1.70158,
                a = 0,
                h = r;
              if (0 === i) return n;
              if (((i /= s), 1 === i)) return n + r;
              a || (a = 0.3 * s);
              var c = t(h, r, a, o);
              return -e(c, i, s) + n;
            }
            function x(e, i, n, r) {
              var s = 1.70158,
                o = 0,
                a = n;
              if (0 === e) return i;
              if (((e /= r), 1 === e)) return i + n;
              o || (o = 0.3 * r);
              var h = t(a, n, o, s);
              return (
                h.a * Math.pow(2, -10 * e) * Math.sin(((e * r - h.s) * (2 * Math.PI)) / h.p) +
                h.c +
                i
              );
            }
            function C(i, n, r, s) {
              var o = 1.70158,
                a = 0,
                h = r;
              if (0 === i) return n;
              if (((i /= s / 2), 2 === i)) return n + r;
              a || (a = s * (0.3 * 1.5));
              var c = t(h, r, a, o);
              return i < 1
                ? -0.5 * e(c, i, s) + n
                : c.a *
                    Math.pow(2, -10 * (i -= 1)) *
                    Math.sin(((i * s - c.s) * (2 * Math.PI)) / c.p) *
                    0.5 +
                    c.c +
                    n;
            }
            function w(t, e, i, n, r) {
              return void 0 === r && (r = 1.70158), i * (t /= n) * t * ((r + 1) * t - r) + e;
            }
            function S(t, e, i, n, r) {
              return (
                void 0 === r && (r = 1.70158), i * ((t = t / n - 1) * t * ((r + 1) * t + r) + 1) + e
              );
            }
            function T(t, e, i, n, r) {
              return (
                void 0 === r && (r = 1.70158),
                (t /= n / 2),
                t < 1
                  ? (i / 2) * (t * t * ((1 + (r *= 1.525)) * t - r)) + e
                  : (i / 2) * ((t -= 2) * t * ((1 + (r *= 1.525)) * t + r) + 2) + e
              );
            }
            function O(t, e, i, n) {
              return i - k(n - t, 0, i, n) + e;
            }
            function k(t, e, i, n) {
              return (t /= n) < 1 / 2.75
                ? i * (7.5625 * t * t) + e
                : t < 2 / 2.75
                ? i * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + e
                : t < 2.5 / 2.75
                ? i * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + e
                : i * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + e;
            }
            function E(t, e, i, n) {
              return t < n / 2
                ? 0.5 * O(2 * t, 0, i, n) + e
                : 0.5 * k(2 * t - n, 0, i, n) + 0.5 * i + e;
            }
            n.util.ease = {
              easeInQuad: function (t, e, i, n) {
                return i * (t /= n) * t + e;
              },
              easeOutQuad: function (t, e, i, n) {
                return -i * (t /= n) * (t - 2) + e;
              },
              easeInOutQuad: function (t, e, i, n) {
                return (
                  (t /= n / 2), t < 1 ? (i / 2) * t * t + e : (-i / 2) * (--t * (t - 2) - 1) + e
                );
              },
              easeInCubic: function (t, e, i, n) {
                return i * (t /= n) * t * t + e;
              },
              easeOutCubic: i,
              easeInOutCubic: r,
              easeInQuart: s,
              easeOutQuart: o,
              easeInOutQuart: a,
              easeInQuint: h,
              easeOutQuint: c,
              easeInOutQuint: l,
              easeInSine: u,
              easeOutSine: f,
              easeInOutSine: d,
              easeInExpo: g,
              easeOutExpo: p,
              easeInOutExpo: m,
              easeInCirc: v,
              easeOutCirc: _,
              easeInOutCirc: y,
              easeInElastic: b,
              easeOutElastic: x,
              easeInOutElastic: C,
              easeInBack: w,
              easeOutBack: S,
              easeInOutBack: T,
              easeInBounce: O,
              easeOutBounce: k,
              easeInOutBounce: E,
            };
          })(),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend,
              n = e.util.object.clone,
              r = e.util.toFixed,
              s = e.util.parseUnit,
              o = e.util.multiplyTransformMatrices,
              a = [
                "path",
                "circle",
                "polygon",
                "polyline",
                "ellipse",
                "rect",
                "line",
                "image",
                "text",
              ],
              h = ["symbol", "image", "marker", "pattern", "view", "svg"],
              c = ["pattern", "defs", "symbol", "metadata", "clipPath", "mask", "desc"],
              l = ["symbol", "g", "a", "svg", "clipPath", "defs"],
              u = {
                cx: "left",
                x: "left",
                r: "radius",
                cy: "top",
                y: "top",
                display: "visible",
                visibility: "visible",
                transform: "transformMatrix",
                "fill-opacity": "fillOpacity",
                "fill-rule": "fillRule",
                "font-family": "fontFamily",
                "font-size": "fontSize",
                "font-style": "fontStyle",
                "font-weight": "fontWeight",
                "letter-spacing": "charSpacing",
                "paint-order": "paintFirst",
                "stroke-dasharray": "strokeDashArray",
                "stroke-dashoffset": "strokeDashOffset",
                "stroke-linecap": "strokeLineCap",
                "stroke-linejoin": "strokeLineJoin",
                "stroke-miterlimit": "strokeMiterLimit",
                "stroke-opacity": "strokeOpacity",
                "stroke-width": "strokeWidth",
                "text-decoration": "textDecoration",
                "text-anchor": "textAnchor",
                opacity: "opacity",
                "clip-path": "clipPath",
                "clip-rule": "clipRule",
                "vector-effect": "strokeUniform",
              },
              f = { stroke: "strokeOpacity", fill: "fillOpacity" };
            function d(t) {
              return t in u ? u[t] : t;
            }
            function g(t, i, n, r) {
              var a,
                h = "[object Array]" === Object.prototype.toString.call(i);
              if (("fill" !== t && "stroke" !== t) || "none" !== i)
                if ("vector-effect" === t) i = "non-scaling-stroke" === i;
                else if ("strokeDashArray" === t)
                  i = "none" === i ? null : i.replace(/,/g, " ").split(/\s+/).map(parseFloat);
                else if ("transformMatrix" === t)
                  i =
                    n && n.transformMatrix
                      ? o(n.transformMatrix, e.parseTransformAttribute(i))
                      : e.parseTransformAttribute(i);
                else if ("visible" === t)
                  (i = "none" !== i && "hidden" !== i), n && !1 === n.visible && (i = !1);
                else if ("opacity" === t)
                  (i = parseFloat(i)), n && "undefined" !== typeof n.opacity && (i *= n.opacity);
                else if ("textAnchor" === t)
                  i = "start" === i ? "left" : "end" === i ? "right" : "center";
                else if ("charSpacing" === t) a = (s(i, r) / r) * 1e3;
                else if ("paintFirst" === t) {
                  var c = i.indexOf("fill"),
                    l = i.indexOf("stroke");
                  i = "fill";
                  ((c > -1 && l > -1 && l < c) || (-1 === c && l > -1)) && (i = "stroke");
                } else {
                  if ("href" === t || "xlink:href" === t) return i;
                  a = h ? i.map(s) : s(i, r);
                }
              else i = "";
              return !h && isNaN(a) ? i : a;
            }
            function p(t) {
              return new RegExp("^(" + t.join("|") + ")\\b", "i");
            }
            function m(t) {
              for (var i in f)
                if ("undefined" !== typeof t[f[i]] && "" !== t[i]) {
                  if ("undefined" === typeof t[i]) {
                    if (!e.Object.prototype[i]) continue;
                    t[i] = e.Object.prototype[i];
                  }
                  if (0 !== t[i].indexOf("url(")) {
                    var n = new e.Color(t[i]);
                    t[i] = n.setAlpha(r(n.getAlpha() * t[f[i]], 2)).toRgba();
                  }
                }
              return t;
            }
            function v(t, e) {
              var i,
                n,
                r,
                s,
                o = [];
              for (r = 0, s = e.length; r < s; r++)
                (i = e[r]),
                  (n = t.getElementsByTagName(i)),
                  (o = o.concat(Array.prototype.slice.call(n)));
              return o;
            }
            function _(t, e) {
              var i, n;
              t.replace(/;\s*$/, "")
                .split(";")
                .forEach(function (t) {
                  var r = t.split(":");
                  (i = r[0].trim().toLowerCase()), (n = r[1].trim()), (e[i] = n);
                });
            }
            function y(t, e) {
              var i, n;
              for (var r in t)
                "undefined" !== typeof t[r] && ((i = r.toLowerCase()), (n = t[r]), (e[i] = n));
            }
            function b(t, i) {
              var n = {};
              for (var r in e.cssRules[i])
                if (x(t, r.split(" "))) for (var s in e.cssRules[i][r]) n[s] = e.cssRules[i][r][s];
              return n;
            }
            function x(t, e) {
              var i,
                n = !0;
              return (i = w(t, e.pop())), i && e.length && (n = C(t, e)), i && n && 0 === e.length;
            }
            function C(t, e) {
              var i,
                n = !0;
              while (t.parentNode && 1 === t.parentNode.nodeType && e.length)
                n && (i = e.pop()), (t = t.parentNode), (n = w(t, i));
              return 0 === e.length;
            }
            function w(t, e) {
              var i,
                n,
                r = t.nodeName,
                s = t.getAttribute("class"),
                o = t.getAttribute("id");
              if (
                ((i = new RegExp("^" + r, "i")),
                (e = e.replace(i, "")),
                o &&
                  e.length &&
                  ((i = new RegExp("#" + o + "(?![a-zA-Z\\-]+)", "i")), (e = e.replace(i, ""))),
                s && e.length)
              )
                for (s = s.split(" "), n = s.length; n--; )
                  (i = new RegExp("\\." + s[n] + "(?![a-zA-Z\\-]+)", "i")), (e = e.replace(i, ""));
              return 0 === e.length;
            }
            function S(t, e) {
              var i;
              if ((t.getElementById && (i = t.getElementById(e)), i)) return i;
              var n,
                r,
                s,
                o = t.getElementsByTagName("*");
              for (r = 0, s = o.length; r < s; r++)
                if (((n = o[r]), e === n.getAttribute("id"))) return n;
            }
            function T(t) {
              var e = v(t, ["use", "svg:use"]),
                i = 0;
              while (e.length && i < e.length) {
                var n,
                  r,
                  s,
                  o,
                  a,
                  h = e[i],
                  c = (h.getAttribute("xlink:href") || h.getAttribute("href")).substr(1),
                  l = h.getAttribute("x") || 0,
                  u = h.getAttribute("y") || 0,
                  f = S(t, c).cloneNode(!0),
                  d = (f.getAttribute("transform") || "") + " translate(" + l + ", " + u + ")",
                  g = e.length;
                if ((k(f), /^svg$/i.test(f.nodeName))) {
                  var p = f.ownerDocument.createElement("g");
                  for (s = 0, o = f.attributes, a = o.length; s < a; s++)
                    (r = o.item(s)), p.setAttribute(r.nodeName, r.nodeValue);
                  while (f.firstChild) p.appendChild(f.firstChild);
                  f = p;
                }
                for (s = 0, o = h.attributes, a = o.length; s < a; s++)
                  (r = o.item(s)),
                    "x" !== r.nodeName &&
                      "y" !== r.nodeName &&
                      "xlink:href" !== r.nodeName &&
                      "href" !== r.nodeName &&
                      ("transform" === r.nodeName
                        ? (d = r.nodeValue + " " + d)
                        : f.setAttribute(r.nodeName, r.nodeValue));
                f.setAttribute("transform", d),
                  f.setAttribute("instantiated_by_use", "1"),
                  f.removeAttribute("id"),
                  (n = h.parentNode),
                  n.replaceChild(f, h),
                  e.length === g && i++;
              }
            }
            (e.svgValidTagNamesRegEx = p(a)),
              (e.svgViewBoxElementsRegEx = p(h)),
              (e.svgInvalidAncestorsRegEx = p(c)),
              (e.svgValidParentsRegEx = p(l)),
              (e.cssRules = {}),
              (e.gradientDefs = {}),
              (e.clipPaths = {}),
              (e.parseTransformAttribute = (function () {
                function t(t, i) {
                  var n = e.util.cos(i[0]),
                    r = e.util.sin(i[0]),
                    s = 0,
                    o = 0;
                  3 === i.length && ((s = i[1]), (o = i[2])),
                    (t[0] = n),
                    (t[1] = r),
                    (t[2] = -r),
                    (t[3] = n),
                    (t[4] = s - (n * s - r * o)),
                    (t[5] = o - (r * s + n * o));
                }
                function i(t, e) {
                  var i = e[0],
                    n = 2 === e.length ? e[1] : e[0];
                  (t[0] = i), (t[3] = n);
                }
                function n(t, i, n) {
                  t[n] = Math.tan(e.util.degreesToRadians(i[0]));
                }
                function r(t, e) {
                  (t[4] = e[0]), 2 === e.length && (t[5] = e[1]);
                }
                var s = e.iMatrix,
                  o = e.reNum,
                  a = "(?:\\s+,?\\s*|,\\s*)",
                  h = "(?:(skewX)\\s*\\(\\s*(" + o + ")\\s*\\))",
                  c = "(?:(skewY)\\s*\\(\\s*(" + o + ")\\s*\\))",
                  l =
                    "(?:(rotate)\\s*\\(\\s*(" +
                    o +
                    ")(?:" +
                    a +
                    "(" +
                    o +
                    ")" +
                    a +
                    "(" +
                    o +
                    "))?\\s*\\))",
                  u = "(?:(scale)\\s*\\(\\s*(" + o + ")(?:" + a + "(" + o + "))?\\s*\\))",
                  f = "(?:(translate)\\s*\\(\\s*(" + o + ")(?:" + a + "(" + o + "))?\\s*\\))",
                  d =
                    "(?:(matrix)\\s*\\(\\s*(" +
                    o +
                    ")" +
                    a +
                    "(" +
                    o +
                    ")" +
                    a +
                    "(" +
                    o +
                    ")" +
                    a +
                    "(" +
                    o +
                    ")" +
                    a +
                    "(" +
                    o +
                    ")" +
                    a +
                    "(" +
                    o +
                    ")\\s*\\))",
                  g = "(?:" + d + "|" + f + "|" + u + "|" + l + "|" + h + "|" + c + ")",
                  p = "(?:" + g + "(?:" + a + "*" + g + ")*)",
                  m = "^\\s*(?:" + p + "?)\\s*$",
                  v = new RegExp(m),
                  _ = new RegExp(g, "g");
                return function (o) {
                  var a = s.concat(),
                    h = [];
                  if (!o || (o && !v.test(o))) return a;
                  o.replace(_, function (o) {
                    var c = new RegExp(g).exec(o).filter(function (t) {
                        return !!t;
                      }),
                      l = c[1],
                      u = c.slice(2).map(parseFloat);
                    switch (l) {
                      case "translate":
                        r(a, u);
                        break;
                      case "rotate":
                        (u[0] = e.util.degreesToRadians(u[0])), t(a, u);
                        break;
                      case "scale":
                        i(a, u);
                        break;
                      case "skewX":
                        n(a, u, 2);
                        break;
                      case "skewY":
                        n(a, u, 1);
                        break;
                      case "matrix":
                        a = u;
                        break;
                    }
                    h.push(a.concat()), (a = s.concat());
                  });
                  var c = h[0];
                  while (h.length > 1) h.shift(), (c = e.util.multiplyTransformMatrices(c, h[0]));
                  return c;
                };
              })());
            var O = new RegExp(
              "^\\s*(" +
                e.reNum +
                "+)\\s*,?\\s*(" +
                e.reNum +
                "+)\\s*,?\\s*(" +
                e.reNum +
                "+)\\s*,?\\s*(" +
                e.reNum +
                "+)\\s*$"
            );
            function k(t) {
              var i,
                n,
                r,
                o,
                a = t.getAttribute("viewBox"),
                h = 1,
                c = 1,
                l = 0,
                u = 0,
                f = t.getAttribute("width"),
                d = t.getAttribute("height"),
                g = t.getAttribute("x") || 0,
                p = t.getAttribute("y") || 0,
                m = t.getAttribute("preserveAspectRatio") || "",
                v = !a || !e.svgViewBoxElementsRegEx.test(t.nodeName) || !(a = a.match(O)),
                _ = !f || !d || "100%" === f || "100%" === d,
                y = v && _,
                b = {},
                x = "",
                C = 0,
                w = 0;
              if (((b.width = 0), (b.height = 0), (b.toBeParsed = y), y)) return b;
              if (v) return (b.width = s(f)), (b.height = s(d)), b;
              if (
                ((l = -parseFloat(a[1])),
                (u = -parseFloat(a[2])),
                (i = parseFloat(a[3])),
                (n = parseFloat(a[4])),
                _
                  ? ((b.width = i), (b.height = n))
                  : ((b.width = s(f)), (b.height = s(d)), (h = b.width / i), (c = b.height / n)),
                (m = e.util.parsePreserveAspectRatioAttribute(m)),
                "none" !== m.alignX &&
                  ("meet" === m.meetOrSlice && (c = h = h > c ? c : h),
                  "slice" === m.meetOrSlice && (c = h = h > c ? h : c),
                  (C = b.width - i * h),
                  (w = b.height - n * h),
                  "Mid" === m.alignX && (C /= 2),
                  "Mid" === m.alignY && (w /= 2),
                  "Min" === m.alignX && (C = 0),
                  "Min" === m.alignY && (w = 0)),
                1 === h && 1 === c && 0 === l && 0 === u && 0 === g && 0 === p)
              )
                return b;
              if (
                ((g || p) && (x = " translate(" + s(g) + " " + s(p) + ") "),
                (r =
                  x + " matrix(" + h + " 0 0 " + c + " " + (l * h + C) + " " + (u * c + w) + ") "),
                (b.viewboxTransform = e.parseTransformAttribute(r)),
                "svg" === t.nodeName)
              ) {
                o = t.ownerDocument.createElement("g");
                while (t.firstChild) o.appendChild(t.firstChild);
                t.appendChild(o);
              } else (o = t), (r = o.getAttribute("transform") + r);
              return o.setAttribute("transform", r), b;
            }
            function E(t, e) {
              while (t && (t = t.parentNode))
                if (
                  t.nodeName &&
                  e.test(t.nodeName.replace("svg:", "")) &&
                  !t.getAttribute("instantiated_by_use")
                )
                  return !0;
              return !1;
            }
            function P(t, e) {
              var i = [
                  "gradientTransform",
                  "x1",
                  "x2",
                  "y1",
                  "y2",
                  "gradientUnits",
                  "cx",
                  "cy",
                  "r",
                  "fx",
                  "fy",
                ],
                n = "xlink:href",
                r = e.getAttribute(n).substr(1),
                s = S(t, r);
              if (
                (s && s.getAttribute(n) && P(t, s),
                i.forEach(function (t) {
                  e.hasAttribute(t) || e.setAttribute(t, s.getAttribute(t));
                }),
                !e.children.length)
              ) {
                var o = s.cloneNode(!0);
                while (o.firstChild) e.appendChild(o.firstChild);
              }
              e.removeAttribute(n);
            }
            e.parseSVGDocument = function (t, i, r, s) {
              if (t) {
                T(t);
                var o,
                  a,
                  h = e.Object.__uid++,
                  c = k(t),
                  l = e.util.toArray(t.getElementsByTagName("*"));
                if (
                  ((c.crossOrigin = s && s.crossOrigin),
                  (c.svgUid = h),
                  0 === l.length && e.isLikelyNode)
                ) {
                  l = t.selectNodes('//*[name(.)!="svg"]');
                  var u = [];
                  for (o = 0, a = l.length; o < a; o++) u[o] = l[o];
                  l = u;
                }
                var f = l.filter(function (t) {
                  return (
                    k(t),
                    e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:", "")) &&
                      !E(t, e.svgInvalidAncestorsRegEx)
                  );
                });
                if (!f || (f && !f.length)) i && i([], {});
                else {
                  var d = {};
                  l
                    .filter(function (t) {
                      return "clipPath" === t.nodeName.replace("svg:", "");
                    })
                    .forEach(function (t) {
                      var i = t.getAttribute("id");
                      d[i] = e.util.toArray(t.getElementsByTagName("*")).filter(function (t) {
                        return e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:", ""));
                      });
                    }),
                    (e.gradientDefs[h] = e.getGradientDefs(t)),
                    (e.cssRules[h] = e.getCSSRules(t)),
                    (e.clipPaths[h] = d),
                    e.parseElements(
                      f,
                      function (t, n) {
                        i &&
                          (i(t, c, n, l),
                          delete e.gradientDefs[h],
                          delete e.cssRules[h],
                          delete e.clipPaths[h]);
                      },
                      n(c),
                      r,
                      s
                    );
                }
              }
            };
            var D = new RegExp(
              "(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*(" +
                e.reNum +
                "(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|" +
                e.reNum +
                "))?\\s+(.*)"
            );
            i(e, {
              parseFontDeclaration: function (t, e) {
                var i = t.match(D);
                if (i) {
                  var n = i[1],
                    r = i[3],
                    o = i[4],
                    a = i[5],
                    h = i[6];
                  n && (e.fontStyle = n),
                    r && (e.fontWeight = isNaN(parseFloat(r)) ? r : parseFloat(r)),
                    o && (e.fontSize = s(o)),
                    h && (e.fontFamily = h),
                    a && (e.lineHeight = "normal" === a ? 1 : a);
                }
              },
              getGradientDefs: function (t) {
                var e,
                  i = [
                    "linearGradient",
                    "radialGradient",
                    "svg:linearGradient",
                    "svg:radialGradient",
                  ],
                  n = v(t, i),
                  r = 0,
                  s = {};
                r = n.length;
                while (r--)
                  (e = n[r]),
                    e.getAttribute("xlink:href") && P(t, e),
                    (s[e.getAttribute("id")] = e);
                return s;
              },
              parseAttributes: function (t, n, r) {
                if (t) {
                  var o,
                    a,
                    h,
                    c = {};
                  "undefined" === typeof r && (r = t.getAttribute("svgUid")),
                    t.parentNode &&
                      e.svgValidParentsRegEx.test(t.parentNode.nodeName) &&
                      (c = e.parseAttributes(t.parentNode, n, r));
                  var l = n.reduce(function (e, i) {
                    return (o = t.getAttribute(i)), o && (e[i] = o), e;
                  }, {});
                  (l = i(l, i(b(t, r), e.parseStyleAttribute(t)))),
                    (a = h = c.fontSize || e.Text.DEFAULT_SVG_FONT_SIZE),
                    l["font-size"] && (l["font-size"] = a = s(l["font-size"], h));
                  var u,
                    f,
                    p = {};
                  for (var v in l) (u = d(v)), (f = g(u, l[v], c, a)), (p[u] = f);
                  p && p.font && e.parseFontDeclaration(p.font, p);
                  var _ = i(c, p);
                  return e.svgValidParentsRegEx.test(t.nodeName) ? _ : m(_);
                }
              },
              parseElements: function (t, i, n, r, s) {
                new e.ElementsParser(t, i, n, r, s).parse();
              },
              parseStyleAttribute: function (t) {
                var e = {},
                  i = t.getAttribute("style");
                return i ? ("string" === typeof i ? _(i, e) : y(i, e), e) : e;
              },
              parsePointsAttribute: function (t) {
                if (!t) return null;
                (t = t.replace(/,/g, " ").trim()), (t = t.split(/\s+/));
                var e,
                  i,
                  n = [];
                for (e = 0, i = t.length; e < i; e += 2)
                  n.push({ x: parseFloat(t[e]), y: parseFloat(t[e + 1]) });
                return n;
              },
              getCSSRules: function (t) {
                var i,
                  n,
                  r,
                  s = t.getElementsByTagName("style"),
                  o = {};
                for (i = 0, n = s.length; i < n; i++) {
                  var a = s[i].textContent || s[i].text;
                  (a = a.replace(/\/\*[\s\S]*?\*\//g, "")),
                    "" !== a.trim() &&
                      ((r = a.match(/[^{]*\{[\s\S]*?\}/g)),
                      (r = r.map(function (t) {
                        return t.trim();
                      })),
                      r.forEach(function (t) {
                        var r = t.match(/([\s\S]*?)\s*\{([^}]*)\}/),
                          s = {},
                          a = r[2].trim(),
                          h = a.replace(/;$/, "").split(/\s*;\s*/);
                        for (i = 0, n = h.length; i < n; i++) {
                          var c = h[i].split(/\s*:\s*/),
                            l = c[0],
                            u = c[1];
                          s[l] = u;
                        }
                        (t = r[1]),
                          t.split(",").forEach(function (t) {
                            (t = t.replace(/^svg/i, "").trim()),
                              "" !== t &&
                                (o[t]
                                  ? e.util.object.extend(o[t], s)
                                  : (o[t] = e.util.object.clone(s)));
                          });
                      }));
                }
                return o;
              },
              loadSVGFromURL: function (t, i, n, r) {
                function s(t) {
                  var s = t.responseXML;
                  if (
                    (s &&
                      !s.documentElement &&
                      e.window.ActiveXObject &&
                      t.responseText &&
                      ((s = new ActiveXObject("Microsoft.XMLDOM")),
                      (s.async = "false"),
                      s.loadXML(t.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i, ""))),
                    !s || !s.documentElement)
                  )
                    return i && i(null), !1;
                  e.parseSVGDocument(
                    s.documentElement,
                    function (t, e, n, r) {
                      i && i(t, e, n, r);
                    },
                    n,
                    r
                  );
                }
                (t = t.replace(/^\n\s*/, "").trim()),
                  new e.util.request(t, { method: "get", onComplete: s });
              },
              loadSVGFromString: function (t, i, n, r) {
                var s;
                if (((t = t.trim()), "undefined" !== typeof DOMParser)) {
                  var o = new DOMParser();
                  o && o.parseFromString && (s = o.parseFromString(t, "text/xml"));
                } else
                  e.window.ActiveXObject &&
                    ((s = new ActiveXObject("Microsoft.XMLDOM")),
                    (s.async = "false"),
                    s.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i, "")));
                e.parseSVGDocument(
                  s.documentElement,
                  function (t, e, n, r) {
                    i(t, e, n, r);
                  },
                  n,
                  r
                );
              },
            });
          })(e),
          (n.ElementsParser = function (t, e, i, n, r) {
            (this.elements = t),
              (this.callback = e),
              (this.options = i),
              (this.reviver = n),
              (this.svgUid = (i && i.svgUid) || 0),
              (this.parsingOptions = r),
              (this.regexUrl = /^url\(['"]?#([^'"]+)['"]?\)/g);
          }),
          (function (t) {
            (t.parse = function () {
              (this.instances = new Array(this.elements.length)),
                (this.numElements = this.elements.length),
                this.createObjects();
            }),
              (t.createObjects = function () {
                var t = this;
                this.elements.forEach(function (e, i) {
                  e.setAttribute("svgUid", t.svgUid), t.createObject(e, i);
                });
              }),
              (t.findTag = function (t) {
                return n[n.util.string.capitalize(t.tagName.replace("svg:", ""))];
              }),
              (t.createObject = function (t, e) {
                var i = this.findTag(t);
                if (i && i.fromElement)
                  try {
                    i.fromElement(t, this.createCallback(e, t), this.options);
                  } catch (r) {
                    n.log(r);
                  }
                else this.checkIfDone();
              }),
              (t.createCallback = function (t, e) {
                var i = this;
                return function (r) {
                  var s;
                  i.resolveGradient(r, "fill"),
                    i.resolveGradient(r, "stroke"),
                    r instanceof n.Image &&
                      r._originalElement &&
                      (s = r.parsePreserveAspectRatioAttribute(e)),
                    r._removeTransformMatrix(s),
                    i.resolveClipPath(r),
                    i.reviver && i.reviver(e, r),
                    (i.instances[t] = r),
                    i.checkIfDone();
                };
              }),
              (t.extractPropertyDefinition = function (t, e, i) {
                var r = t[e];
                if (/^url\(/.test(r)) {
                  var s = this.regexUrl.exec(r)[1];
                  return (this.regexUrl.lastIndex = 0), n[i][this.svgUid][s];
                }
              }),
              (t.resolveGradient = function (t, e) {
                var i = this.extractPropertyDefinition(t, e, "gradientDefs");
                i && t.set(e, n.Gradient.fromElement(i, t));
              }),
              (t.createClipPathCallback = function (t, e) {
                return function (t) {
                  t._removeTransformMatrix(), (t.fillRule = t.clipRule), e.push(t);
                };
              }),
              (t.resolveClipPath = function (t) {
                var e,
                  i,
                  r,
                  s,
                  o,
                  a = this.extractPropertyDefinition(t, "clipPath", "clipPaths");
                if (a) {
                  (s = []), (r = n.util.invertTransform(t.calcTransformMatrix()));
                  for (var h = 0; h < a.length; h++)
                    (e = a[h]),
                      (i = this.findTag(e)),
                      i.fromElement(e, this.createClipPathCallback(t, s), this.options);
                  (a = 1 === s.length ? s[0] : new n.Group(s)),
                    (o = n.util.multiplyTransformMatrices(r, a.calcTransformMatrix()));
                  var c = n.util.qrDecompose(o);
                  (a.flipX = !1),
                    (a.flipY = !1),
                    a.set("scaleX", c.scaleX),
                    a.set("scaleY", c.scaleY),
                    (a.angle = c.angle),
                    (a.skewX = c.skewX),
                    (a.skewY = 0),
                    a.setPositionByOrigin({ x: c.translateX, y: c.translateY }, "center", "center"),
                    (t.clipPath = a);
                }
              }),
              (t.checkIfDone = function () {
                0 === --this.numElements &&
                  ((this.instances = this.instances.filter(function (t) {
                    return null != t;
                  })),
                  this.callback(this.instances, this.elements));
              });
          })(n.ElementsParser.prototype),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {});
            function i(t, e) {
              (this.x = t), (this.y = e);
            }
            e.Point
              ? e.warn("fabric.Point is already defined")
              : ((e.Point = i),
                (i.prototype = {
                  type: "point",
                  constructor: i,
                  add: function (t) {
                    return new i(this.x + t.x, this.y + t.y);
                  },
                  addEquals: function (t) {
                    return (this.x += t.x), (this.y += t.y), this;
                  },
                  scalarAdd: function (t) {
                    return new i(this.x + t, this.y + t);
                  },
                  scalarAddEquals: function (t) {
                    return (this.x += t), (this.y += t), this;
                  },
                  subtract: function (t) {
                    return new i(this.x - t.x, this.y - t.y);
                  },
                  subtractEquals: function (t) {
                    return (this.x -= t.x), (this.y -= t.y), this;
                  },
                  scalarSubtract: function (t) {
                    return new i(this.x - t, this.y - t);
                  },
                  scalarSubtractEquals: function (t) {
                    return (this.x -= t), (this.y -= t), this;
                  },
                  multiply: function (t) {
                    return new i(this.x * t, this.y * t);
                  },
                  multiplyEquals: function (t) {
                    return (this.x *= t), (this.y *= t), this;
                  },
                  divide: function (t) {
                    return new i(this.x / t, this.y / t);
                  },
                  divideEquals: function (t) {
                    return (this.x /= t), (this.y /= t), this;
                  },
                  eq: function (t) {
                    return this.x === t.x && this.y === t.y;
                  },
                  lt: function (t) {
                    return this.x < t.x && this.y < t.y;
                  },
                  lte: function (t) {
                    return this.x <= t.x && this.y <= t.y;
                  },
                  gt: function (t) {
                    return this.x > t.x && this.y > t.y;
                  },
                  gte: function (t) {
                    return this.x >= t.x && this.y >= t.y;
                  },
                  lerp: function (t, e) {
                    return (
                      "undefined" === typeof e && (e = 0.5),
                      (e = Math.max(Math.min(1, e), 0)),
                      new i(this.x + (t.x - this.x) * e, this.y + (t.y - this.y) * e)
                    );
                  },
                  distanceFrom: function (t) {
                    var e = this.x - t.x,
                      i = this.y - t.y;
                    return Math.sqrt(e * e + i * i);
                  },
                  midPointFrom: function (t) {
                    return this.lerp(t);
                  },
                  min: function (t) {
                    return new i(Math.min(this.x, t.x), Math.min(this.y, t.y));
                  },
                  max: function (t) {
                    return new i(Math.max(this.x, t.x), Math.max(this.y, t.y));
                  },
                  toString: function () {
                    return this.x + "," + this.y;
                  },
                  setXY: function (t, e) {
                    return (this.x = t), (this.y = e), this;
                  },
                  setX: function (t) {
                    return (this.x = t), this;
                  },
                  setY: function (t) {
                    return (this.y = t), this;
                  },
                  setFromPoint: function (t) {
                    return (this.x = t.x), (this.y = t.y), this;
                  },
                  swap: function (t) {
                    var e = this.x,
                      i = this.y;
                    (this.x = t.x), (this.y = t.y), (t.x = e), (t.y = i);
                  },
                  clone: function () {
                    return new i(this.x, this.y);
                  },
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {});
            function i(t) {
              (this.status = t), (this.points = []);
            }
            e.Intersection
              ? e.warn("fabric.Intersection is already defined")
              : ((e.Intersection = i),
                (e.Intersection.prototype = {
                  constructor: i,
                  appendPoint: function (t) {
                    return this.points.push(t), this;
                  },
                  appendPoints: function (t) {
                    return (this.points = this.points.concat(t)), this;
                  },
                }),
                (e.Intersection.intersectLineLine = function (t, n, r, s) {
                  var o,
                    a = (s.x - r.x) * (t.y - r.y) - (s.y - r.y) * (t.x - r.x),
                    h = (n.x - t.x) * (t.y - r.y) - (n.y - t.y) * (t.x - r.x),
                    c = (s.y - r.y) * (n.x - t.x) - (s.x - r.x) * (n.y - t.y);
                  if (0 !== c) {
                    var l = a / c,
                      u = h / c;
                    0 <= l && l <= 1 && 0 <= u && u <= 1
                      ? ((o = new i("Intersection")),
                        o.appendPoint(new e.Point(t.x + l * (n.x - t.x), t.y + l * (n.y - t.y))))
                      : (o = new i());
                  } else o = new i(0 === a || 0 === h ? "Coincident" : "Parallel");
                  return o;
                }),
                (e.Intersection.intersectLinePolygon = function (t, e, n) {
                  var r,
                    s,
                    o,
                    a,
                    h = new i(),
                    c = n.length;
                  for (a = 0; a < c; a++)
                    (r = n[a]),
                      (s = n[(a + 1) % c]),
                      (o = i.intersectLineLine(t, e, r, s)),
                      h.appendPoints(o.points);
                  return h.points.length > 0 && (h.status = "Intersection"), h;
                }),
                (e.Intersection.intersectPolygonPolygon = function (t, e) {
                  var n,
                    r = new i(),
                    s = t.length;
                  for (n = 0; n < s; n++) {
                    var o = t[n],
                      a = t[(n + 1) % s],
                      h = i.intersectLinePolygon(o, a, e);
                    r.appendPoints(h.points);
                  }
                  return r.points.length > 0 && (r.status = "Intersection"), r;
                }),
                (e.Intersection.intersectPolygonRectangle = function (t, n, r) {
                  var s = n.min(r),
                    o = n.max(r),
                    a = new e.Point(o.x, s.y),
                    h = new e.Point(s.x, o.y),
                    c = i.intersectLinePolygon(s, a, t),
                    l = i.intersectLinePolygon(a, o, t),
                    u = i.intersectLinePolygon(o, h, t),
                    f = i.intersectLinePolygon(h, s, t),
                    d = new i();
                  return (
                    d.appendPoints(c.points),
                    d.appendPoints(l.points),
                    d.appendPoints(u.points),
                    d.appendPoints(f.points),
                    d.points.length > 0 && (d.status = "Intersection"),
                    d
                  );
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {});
            function i(t) {
              t ? this._tryParsingColor(t) : this.setSource([0, 0, 0, 1]);
            }
            function n(t, e, i) {
              return (
                i < 0 && (i += 1),
                i > 1 && (i -= 1),
                i < 1 / 6
                  ? t + 6 * (e - t) * i
                  : i < 0.5
                  ? e
                  : i < 2 / 3
                  ? t + (e - t) * (2 / 3 - i) * 6
                  : t
              );
            }
            e.Color
              ? e.warn("fabric.Color is already defined.")
              : ((e.Color = i),
                (e.Color.prototype = {
                  _tryParsingColor: function (t) {
                    var e;
                    t in i.colorNameMap && (t = i.colorNameMap[t]),
                      "transparent" === t && (e = [255, 255, 255, 0]),
                      e || (e = i.sourceFromHex(t)),
                      e || (e = i.sourceFromRgb(t)),
                      e || (e = i.sourceFromHsl(t)),
                      e || (e = [0, 0, 0, 1]),
                      e && this.setSource(e);
                  },
                  _rgbToHsl: function (t, i, n) {
                    (t /= 255), (i /= 255), (n /= 255);
                    var r,
                      s,
                      o,
                      a = e.util.array.max([t, i, n]),
                      h = e.util.array.min([t, i, n]);
                    if (((o = (a + h) / 2), a === h)) r = s = 0;
                    else {
                      var c = a - h;
                      switch (((s = o > 0.5 ? c / (2 - a - h) : c / (a + h)), a)) {
                        case t:
                          r = (i - n) / c + (i < n ? 6 : 0);
                          break;
                        case i:
                          r = (n - t) / c + 2;
                          break;
                        case n:
                          r = (t - i) / c + 4;
                          break;
                      }
                      r /= 6;
                    }
                    return [Math.round(360 * r), Math.round(100 * s), Math.round(100 * o)];
                  },
                  getSource: function () {
                    return this._source;
                  },
                  setSource: function (t) {
                    this._source = t;
                  },
                  toRgb: function () {
                    var t = this.getSource();
                    return "rgb(" + t[0] + "," + t[1] + "," + t[2] + ")";
                  },
                  toRgba: function () {
                    var t = this.getSource();
                    return "rgba(" + t[0] + "," + t[1] + "," + t[2] + "," + t[3] + ")";
                  },
                  toHsl: function () {
                    var t = this.getSource(),
                      e = this._rgbToHsl(t[0], t[1], t[2]);
                    return "hsl(" + e[0] + "," + e[1] + "%," + e[2] + "%)";
                  },
                  toHsla: function () {
                    var t = this.getSource(),
                      e = this._rgbToHsl(t[0], t[1], t[2]);
                    return "hsla(" + e[0] + "," + e[1] + "%," + e[2] + "%," + t[3] + ")";
                  },
                  toHex: function () {
                    var t,
                      e,
                      i,
                      n = this.getSource();
                    return (
                      (t = n[0].toString(16)),
                      (t = 1 === t.length ? "0" + t : t),
                      (e = n[1].toString(16)),
                      (e = 1 === e.length ? "0" + e : e),
                      (i = n[2].toString(16)),
                      (i = 1 === i.length ? "0" + i : i),
                      t.toUpperCase() + e.toUpperCase() + i.toUpperCase()
                    );
                  },
                  toHexa: function () {
                    var t,
                      e = this.getSource();
                    return (
                      (t = Math.round(255 * e[3])),
                      (t = t.toString(16)),
                      (t = 1 === t.length ? "0" + t : t),
                      this.toHex() + t.toUpperCase()
                    );
                  },
                  getAlpha: function () {
                    return this.getSource()[3];
                  },
                  setAlpha: function (t) {
                    var e = this.getSource();
                    return (e[3] = t), this.setSource(e), this;
                  },
                  toGrayscale: function () {
                    var t = this.getSource(),
                      e = parseInt((0.3 * t[0] + 0.59 * t[1] + 0.11 * t[2]).toFixed(0), 10),
                      i = t[3];
                    return this.setSource([e, e, e, i]), this;
                  },
                  toBlackWhite: function (t) {
                    var e = this.getSource(),
                      i = (0.3 * e[0] + 0.59 * e[1] + 0.11 * e[2]).toFixed(0),
                      n = e[3];
                    return (
                      (t = t || 127),
                      (i = Number(i) < Number(t) ? 0 : 255),
                      this.setSource([i, i, i, n]),
                      this
                    );
                  },
                  overlayWith: function (t) {
                    t instanceof i || (t = new i(t));
                    var e,
                      n = [],
                      r = this.getAlpha(),
                      s = 0.5,
                      o = this.getSource(),
                      a = t.getSource();
                    for (e = 0; e < 3; e++) n.push(Math.round(o[e] * (1 - s) + a[e] * s));
                    return (n[3] = r), this.setSource(n), this;
                  },
                }),
                (e.Color.reRGBa =
                  /^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i),
                (e.Color.reHSLa =
                  /^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i),
                (e.Color.reHex = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i),
                (e.Color.colorNameMap = {
                  aliceblue: "#F0F8FF",
                  antiquewhite: "#FAEBD7",
                  aqua: "#00FFFF",
                  aquamarine: "#7FFFD4",
                  azure: "#F0FFFF",
                  beige: "#F5F5DC",
                  bisque: "#FFE4C4",
                  black: "#000000",
                  blanchedalmond: "#FFEBCD",
                  blue: "#0000FF",
                  blueviolet: "#8A2BE2",
                  brown: "#A52A2A",
                  burlywood: "#DEB887",
                  cadetblue: "#5F9EA0",
                  chartreuse: "#7FFF00",
                  chocolate: "#D2691E",
                  coral: "#FF7F50",
                  cornflowerblue: "#6495ED",
                  cornsilk: "#FFF8DC",
                  crimson: "#DC143C",
                  cyan: "#00FFFF",
                  darkblue: "#00008B",
                  darkcyan: "#008B8B",
                  darkgoldenrod: "#B8860B",
                  darkgray: "#A9A9A9",
                  darkgrey: "#A9A9A9",
                  darkgreen: "#006400",
                  darkkhaki: "#BDB76B",
                  darkmagenta: "#8B008B",
                  darkolivegreen: "#556B2F",
                  darkorange: "#FF8C00",
                  darkorchid: "#9932CC",
                  darkred: "#8B0000",
                  darksalmon: "#E9967A",
                  darkseagreen: "#8FBC8F",
                  darkslateblue: "#483D8B",
                  darkslategray: "#2F4F4F",
                  darkslategrey: "#2F4F4F",
                  darkturquoise: "#00CED1",
                  darkviolet: "#9400D3",
                  deeppink: "#FF1493",
                  deepskyblue: "#00BFFF",
                  dimgray: "#696969",
                  dimgrey: "#696969",
                  dodgerblue: "#1E90FF",
                  firebrick: "#B22222",
                  floralwhite: "#FFFAF0",
                  forestgreen: "#228B22",
                  fuchsia: "#FF00FF",
                  gainsboro: "#DCDCDC",
                  ghostwhite: "#F8F8FF",
                  gold: "#FFD700",
                  goldenrod: "#DAA520",
                  gray: "#808080",
                  grey: "#808080",
                  green: "#008000",
                  greenyellow: "#ADFF2F",
                  honeydew: "#F0FFF0",
                  hotpink: "#FF69B4",
                  indianred: "#CD5C5C",
                  indigo: "#4B0082",
                  ivory: "#FFFFF0",
                  khaki: "#F0E68C",
                  lavender: "#E6E6FA",
                  lavenderblush: "#FFF0F5",
                  lawngreen: "#7CFC00",
                  lemonchiffon: "#FFFACD",
                  lightblue: "#ADD8E6",
                  lightcoral: "#F08080",
                  lightcyan: "#E0FFFF",
                  lightgoldenrodyellow: "#FAFAD2",
                  lightgray: "#D3D3D3",
                  lightgrey: "#D3D3D3",
                  lightgreen: "#90EE90",
                  lightpink: "#FFB6C1",
                  lightsalmon: "#FFA07A",
                  lightseagreen: "#20B2AA",
                  lightskyblue: "#87CEFA",
                  lightslategray: "#778899",
                  lightslategrey: "#778899",
                  lightsteelblue: "#B0C4DE",
                  lightyellow: "#FFFFE0",
                  lime: "#00FF00",
                  limegreen: "#32CD32",
                  linen: "#FAF0E6",
                  magenta: "#FF00FF",
                  maroon: "#800000",
                  mediumaquamarine: "#66CDAA",
                  mediumblue: "#0000CD",
                  mediumorchid: "#BA55D3",
                  mediumpurple: "#9370DB",
                  mediumseagreen: "#3CB371",
                  mediumslateblue: "#7B68EE",
                  mediumspringgreen: "#00FA9A",
                  mediumturquoise: "#48D1CC",
                  mediumvioletred: "#C71585",
                  midnightblue: "#191970",
                  mintcream: "#F5FFFA",
                  mistyrose: "#FFE4E1",
                  moccasin: "#FFE4B5",
                  navajowhite: "#FFDEAD",
                  navy: "#000080",
                  oldlace: "#FDF5E6",
                  olive: "#808000",
                  olivedrab: "#6B8E23",
                  orange: "#FFA500",
                  orangered: "#FF4500",
                  orchid: "#DA70D6",
                  palegoldenrod: "#EEE8AA",
                  palegreen: "#98FB98",
                  paleturquoise: "#AFEEEE",
                  palevioletred: "#DB7093",
                  papayawhip: "#FFEFD5",
                  peachpuff: "#FFDAB9",
                  peru: "#CD853F",
                  pink: "#FFC0CB",
                  plum: "#DDA0DD",
                  powderblue: "#B0E0E6",
                  purple: "#800080",
                  rebeccapurple: "#663399",
                  red: "#FF0000",
                  rosybrown: "#BC8F8F",
                  royalblue: "#4169E1",
                  saddlebrown: "#8B4513",
                  salmon: "#FA8072",
                  sandybrown: "#F4A460",
                  seagreen: "#2E8B57",
                  seashell: "#FFF5EE",
                  sienna: "#A0522D",
                  silver: "#C0C0C0",
                  skyblue: "#87CEEB",
                  slateblue: "#6A5ACD",
                  slategray: "#708090",
                  slategrey: "#708090",
                  snow: "#FFFAFA",
                  springgreen: "#00FF7F",
                  steelblue: "#4682B4",
                  tan: "#D2B48C",
                  teal: "#008080",
                  thistle: "#D8BFD8",
                  tomato: "#FF6347",
                  turquoise: "#40E0D0",
                  violet: "#EE82EE",
                  wheat: "#F5DEB3",
                  white: "#FFFFFF",
                  whitesmoke: "#F5F5F5",
                  yellow: "#FFFF00",
                  yellowgreen: "#9ACD32",
                }),
                (e.Color.fromRgb = function (t) {
                  return i.fromSource(i.sourceFromRgb(t));
                }),
                (e.Color.sourceFromRgb = function (t) {
                  var e = t.match(i.reRGBa);
                  if (e) {
                    var n =
                        (parseInt(e[1], 10) / (/%$/.test(e[1]) ? 100 : 1)) *
                        (/%$/.test(e[1]) ? 255 : 1),
                      r =
                        (parseInt(e[2], 10) / (/%$/.test(e[2]) ? 100 : 1)) *
                        (/%$/.test(e[2]) ? 255 : 1),
                      s =
                        (parseInt(e[3], 10) / (/%$/.test(e[3]) ? 100 : 1)) *
                        (/%$/.test(e[3]) ? 255 : 1);
                    return [
                      parseInt(n, 10),
                      parseInt(r, 10),
                      parseInt(s, 10),
                      e[4] ? parseFloat(e[4]) : 1,
                    ];
                  }
                }),
                (e.Color.fromRgba = i.fromRgb),
                (e.Color.fromHsl = function (t) {
                  return i.fromSource(i.sourceFromHsl(t));
                }),
                (e.Color.sourceFromHsl = function (t) {
                  var e = t.match(i.reHSLa);
                  if (e) {
                    var r,
                      s,
                      o,
                      a = (((parseFloat(e[1]) % 360) + 360) % 360) / 360,
                      h = parseFloat(e[2]) / (/%$/.test(e[2]) ? 100 : 1),
                      c = parseFloat(e[3]) / (/%$/.test(e[3]) ? 100 : 1);
                    if (0 === h) r = s = o = c;
                    else {
                      var l = c <= 0.5 ? c * (h + 1) : c + h - c * h,
                        u = 2 * c - l;
                      (r = n(u, l, a + 1 / 3)), (s = n(u, l, a)), (o = n(u, l, a - 1 / 3));
                    }
                    return [
                      Math.round(255 * r),
                      Math.round(255 * s),
                      Math.round(255 * o),
                      e[4] ? parseFloat(e[4]) : 1,
                    ];
                  }
                }),
                (e.Color.fromHsla = i.fromHsl),
                (e.Color.fromHex = function (t) {
                  return i.fromSource(i.sourceFromHex(t));
                }),
                (e.Color.sourceFromHex = function (t) {
                  if (t.match(i.reHex)) {
                    var e = t.slice(t.indexOf("#") + 1),
                      n = 3 === e.length || 4 === e.length,
                      r = 8 === e.length || 4 === e.length,
                      s = n ? e.charAt(0) + e.charAt(0) : e.substring(0, 2),
                      o = n ? e.charAt(1) + e.charAt(1) : e.substring(2, 4),
                      a = n ? e.charAt(2) + e.charAt(2) : e.substring(4, 6),
                      h = r ? (n ? e.charAt(3) + e.charAt(3) : e.substring(6, 8)) : "FF";
                    return [
                      parseInt(s, 16),
                      parseInt(o, 16),
                      parseInt(a, 16),
                      parseFloat((parseInt(h, 16) / 255).toFixed(2)),
                    ];
                  }
                }),
                (e.Color.fromSource = function (t) {
                  var e = new i();
                  return e.setSource(t), e;
                }));
          })(e),
          (function () {
            function t(t) {
              var e,
                i,
                r,
                s,
                o = t.getAttribute("style"),
                a = t.getAttribute("offset") || 0;
              if (
                ((a = parseFloat(a) / (/%$/.test(a) ? 100 : 1)), (a = a < 0 ? 0 : a > 1 ? 1 : a), o)
              ) {
                var h = o.split(/\s*;\s*/);
                for ("" === h[h.length - 1] && h.pop(), s = h.length; s--; ) {
                  var c = h[s].split(/\s*:\s*/),
                    l = c[0].trim(),
                    u = c[1].trim();
                  "stop-color" === l ? (e = u) : "stop-opacity" === l && (r = u);
                }
              }
              return (
                e || (e = t.getAttribute("stop-color") || "rgb(0,0,0)"),
                r || (r = t.getAttribute("stop-opacity")),
                (e = new n.Color(e)),
                (i = e.getAlpha()),
                (r = isNaN(parseFloat(r)) ? 1 : parseFloat(r)),
                (r *= i),
                { offset: a, color: e.toRgb(), opacity: r }
              );
            }
            function e(t) {
              return {
                x1: t.getAttribute("x1") || 0,
                y1: t.getAttribute("y1") || 0,
                x2: t.getAttribute("x2") || "100%",
                y2: t.getAttribute("y2") || 0,
              };
            }
            function i(t) {
              return {
                x1: t.getAttribute("fx") || t.getAttribute("cx") || "50%",
                y1: t.getAttribute("fy") || t.getAttribute("cy") || "50%",
                r1: 0,
                x2: t.getAttribute("cx") || "50%",
                y2: t.getAttribute("cy") || "50%",
                r2: t.getAttribute("r") || "50%",
              };
            }
            var r = n.util.object.clone;
            function s(t, e, i) {
              var n,
                r = 0,
                s = 1,
                o = "";
              for (var a in e)
                "Infinity" === e[a] ? (e[a] = 1) : "-Infinity" === e[a] && (e[a] = 0),
                  (n = parseFloat(e[a], 10)),
                  (s = "string" === typeof e[a] && /^(\d+\.\d+)%|(\d+)%$/.test(e[a]) ? 0.01 : 1),
                  "x1" === a || "x2" === a || "r2" === a
                    ? ((s *= "objectBoundingBox" === i ? t.width : 1),
                      (r = ("objectBoundingBox" === i && t.left) || 0))
                    : ("y1" !== a && "y2" !== a) ||
                      ((s *= "objectBoundingBox" === i ? t.height : 1),
                      (r = ("objectBoundingBox" === i && t.top) || 0)),
                  (e[a] = n * s + r);
              if (
                "ellipse" === t.type &&
                null !== e.r2 &&
                "objectBoundingBox" === i &&
                t.rx !== t.ry
              ) {
                var h = t.ry / t.rx;
                (o = " scale(1, " + h + ")"), e.y1 && (e.y1 /= h), e.y2 && (e.y2 /= h);
              }
              return o;
            }
            (n.Gradient = n.util.createClass({
              offsetX: 0,
              offsetY: 0,
              initialize: function (t) {
                t || (t = {});
                var e = {};
                (this.id = n.Object.__uid++),
                  (this.type = t.type || "linear"),
                  (e = {
                    x1: t.coords.x1 || 0,
                    y1: t.coords.y1 || 0,
                    x2: t.coords.x2 || 0,
                    y2: t.coords.y2 || 0,
                  }),
                  "radial" === this.type && ((e.r1 = t.coords.r1 || 0), (e.r2 = t.coords.r2 || 0)),
                  (this.coords = e),
                  (this.colorStops = t.colorStops.slice()),
                  t.gradientTransform && (this.gradientTransform = t.gradientTransform),
                  (this.offsetX = t.offsetX || this.offsetX),
                  (this.offsetY = t.offsetY || this.offsetY);
              },
              addColorStop: function (t) {
                for (var e in t) {
                  var i = new n.Color(t[e]);
                  this.colorStops.push({
                    offset: parseFloat(e),
                    color: i.toRgb(),
                    opacity: i.getAlpha(),
                  });
                }
                return this;
              },
              toObject: function (t) {
                var e = {
                  type: this.type,
                  coords: this.coords,
                  colorStops: this.colorStops,
                  offsetX: this.offsetX,
                  offsetY: this.offsetY,
                  gradientTransform: this.gradientTransform
                    ? this.gradientTransform.concat()
                    : this.gradientTransform,
                };
                return n.util.populateWithProperties(this, e, t), e;
              },
              toSVG: function (t) {
                var e,
                  i,
                  s,
                  o,
                  a = r(this.coords, !0),
                  h = r(this.colorStops, !0),
                  c = a.r1 > a.r2,
                  l = this.gradientTransform ? this.gradientTransform.concat() : n.iMatrix.concat(),
                  u = t.width / 2 - this.offsetX,
                  f = t.height / 2 - this.offsetY;
                if (
                  (h.sort(function (t, e) {
                    return t.offset - e.offset;
                  }),
                  "path" === t.type && ((u -= t.pathOffset.x), (f -= t.pathOffset.y)),
                  (l[4] -= u),
                  (l[5] -= f),
                  (o = 'id="SVGID_' + this.id + '" gradientUnits="userSpaceOnUse"'),
                  (o += ' gradientTransform="matrix(' + l.join(" ") + ')" '),
                  "linear" === this.type
                    ? (s = [
                        "<linearGradient ",
                        o,
                        ' x1="',
                        a.x1,
                        '" y1="',
                        a.y1,
                        '" x2="',
                        a.x2,
                        '" y2="',
                        a.y2,
                        '">\n',
                      ])
                    : "radial" === this.type &&
                      (s = [
                        "<radialGradient ",
                        o,
                        ' cx="',
                        c ? a.x1 : a.x2,
                        '" cy="',
                        c ? a.y1 : a.y2,
                        '" r="',
                        c ? a.r1 : a.r2,
                        '" fx="',
                        c ? a.x2 : a.x1,
                        '" fy="',
                        c ? a.y2 : a.y1,
                        '">\n',
                      ]),
                  "radial" === this.type)
                ) {
                  if (c)
                    for (h = h.concat(), h.reverse(), e = 0, i = h.length; e < i; e++)
                      h[e].offset = 1 - h[e].offset;
                  var d = Math.min(a.r1, a.r2);
                  if (d > 0) {
                    var g = Math.max(a.r1, a.r2),
                      p = d / g;
                    for (e = 0, i = h.length; e < i; e++) h[e].offset += p * (1 - h[e].offset);
                  }
                }
                for (e = 0, i = h.length; e < i; e++) {
                  var m = h[e];
                  s.push(
                    "<stop ",
                    'offset="',
                    100 * m.offset + "%",
                    '" style="stop-color:',
                    m.color,
                    "undefined" !== typeof m.opacity ? ";stop-opacity: " + m.opacity : ";",
                    '"/>\n'
                  );
                }
                return (
                  s.push("linear" === this.type ? "</linearGradient>\n" : "</radialGradient>\n"),
                  s.join("")
                );
              },
              toLive: function (t) {
                var e,
                  i,
                  r,
                  s = n.util.object.clone(this.coords);
                if (this.type) {
                  for (
                    "linear" === this.type
                      ? (e = t.createLinearGradient(s.x1, s.y1, s.x2, s.y2))
                      : "radial" === this.type &&
                        (e = t.createRadialGradient(s.x1, s.y1, s.r1, s.x2, s.y2, s.r2)),
                      i = 0,
                      r = this.colorStops.length;
                    i < r;
                    i++
                  ) {
                    var o = this.colorStops[i].color,
                      a = this.colorStops[i].opacity,
                      h = this.colorStops[i].offset;
                    "undefined" !== typeof a && (o = new n.Color(o).setAlpha(a).toRgba()),
                      e.addColorStop(h, o);
                  }
                  return e;
                }
              },
            })),
              n.util.object.extend(n.Gradient, {
                fromElement: function (r, o) {
                  var a,
                    h,
                    c,
                    l,
                    u = r.getElementsByTagName("stop"),
                    f = r.getAttribute("gradientUnits") || "objectBoundingBox",
                    d = r.getAttribute("gradientTransform"),
                    g = [];
                  for (
                    a =
                      "linearGradient" === r.nodeName || "LINEARGRADIENT" === r.nodeName
                        ? "linear"
                        : "radial",
                      "linear" === a ? (h = e(r)) : "radial" === a && (h = i(r)),
                      l = u.length;
                    l--;

                  )
                    g.push(t(u[l]));
                  c = s(o, h, f);
                  var p = new n.Gradient({
                    type: a,
                    coords: h,
                    colorStops: g,
                    offsetX: -o.left,
                    offsetY: -o.top,
                  });
                  return (
                    (d || "" !== c) &&
                      (p.gradientTransform = n.parseTransformAttribute((d || "") + c)),
                    p
                  );
                },
                forObject: function (t, e) {
                  return e || (e = {}), s(t, e.coords, "userSpaceOnUse"), new n.Gradient(e);
                },
              });
          })(),
          (function () {
            "use strict";
            var t = n.util.toFixed;
            n.Pattern = n.util.createClass({
              repeat: "repeat",
              offsetX: 0,
              offsetY: 0,
              crossOrigin: "",
              patternTransform: null,
              initialize: function (t, e) {
                if (
                  (t || (t = {}),
                  (this.id = n.Object.__uid++),
                  this.setOptions(t),
                  !t.source || (t.source && "string" !== typeof t.source))
                )
                  e && e(this);
                else if ("undefined" !== typeof n.util.getFunctionBody(t.source))
                  (this.source = new Function(n.util.getFunctionBody(t.source))), e && e(this);
                else {
                  var i = this;
                  (this.source = n.util.createImage()),
                    n.util.loadImage(
                      t.source,
                      function (t) {
                        (i.source = t), e && e(i);
                      },
                      null,
                      this.crossOrigin
                    );
                }
              },
              toObject: function (e) {
                var i,
                  r,
                  s = n.Object.NUM_FRACTION_DIGITS;
                return (
                  "function" === typeof this.source
                    ? (i = String(this.source))
                    : "string" === typeof this.source.src
                    ? (i = this.source.src)
                    : "object" === typeof this.source &&
                      this.source.toDataURL &&
                      (i = this.source.toDataURL()),
                  (r = {
                    type: "pattern",
                    source: i,
                    repeat: this.repeat,
                    crossOrigin: this.crossOrigin,
                    offsetX: t(this.offsetX, s),
                    offsetY: t(this.offsetY, s),
                    patternTransform: this.patternTransform ? this.patternTransform.concat() : null,
                  }),
                  n.util.populateWithProperties(this, r, e),
                  r
                );
              },
              toSVG: function (t) {
                var e = "function" === typeof this.source ? this.source() : this.source,
                  i = e.width / t.width,
                  n = e.height / t.height,
                  r = this.offsetX / t.width,
                  s = this.offsetY / t.height,
                  o = "";
                return (
                  ("repeat-x" !== this.repeat && "no-repeat" !== this.repeat) ||
                    ((n = 1), s && (n += Math.abs(s))),
                  ("repeat-y" !== this.repeat && "no-repeat" !== this.repeat) ||
                    ((i = 1), r && (i += Math.abs(r))),
                  e.src ? (o = e.src) : e.toDataURL && (o = e.toDataURL()),
                  '<pattern id="SVGID_' +
                    this.id +
                    '" x="' +
                    r +
                    '" y="' +
                    s +
                    '" width="' +
                    i +
                    '" height="' +
                    n +
                    '">\n<image x="0" y="0" width="' +
                    e.width +
                    '" height="' +
                    e.height +
                    '" xlink:href="' +
                    o +
                    '"></image>\n</pattern>\n'
                );
              },
              setOptions: function (t) {
                for (var e in t) this[e] = t[e];
              },
              toLive: function (t) {
                var e = "function" === typeof this.source ? this.source() : this.source;
                if (!e) return "";
                if ("undefined" !== typeof e.src) {
                  if (!e.complete) return "";
                  if (0 === e.naturalWidth || 0 === e.naturalHeight) return "";
                }
                return t.createPattern(e, this.repeat);
              },
            });
          })(),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.toFixed;
            e.Shadow
              ? e.warn("fabric.Shadow is already defined.")
              : ((e.Shadow = e.util.createClass({
                  color: "rgb(0,0,0)",
                  blur: 0,
                  offsetX: 0,
                  offsetY: 0,
                  affectStroke: !1,
                  includeDefaultValues: !0,
                  initialize: function (t) {
                    for (var i in ("string" === typeof t && (t = this._parseShadow(t)), t))
                      this[i] = t[i];
                    this.id = e.Object.__uid++;
                  },
                  _parseShadow: function (t) {
                    var i = t.trim(),
                      n = e.Shadow.reOffsetsAndBlur.exec(i) || [],
                      r = i.replace(e.Shadow.reOffsetsAndBlur, "") || "rgb(0,0,0)";
                    return {
                      color: r.trim(),
                      offsetX: parseInt(n[1], 10) || 0,
                      offsetY: parseInt(n[2], 10) || 0,
                      blur: parseInt(n[3], 10) || 0,
                    };
                  },
                  toString: function () {
                    return [this.offsetX, this.offsetY, this.blur, this.color].join("px ");
                  },
                  toSVG: function (t) {
                    var n = 40,
                      r = 40,
                      s = e.Object.NUM_FRACTION_DIGITS,
                      o = e.util.rotateVector(
                        { x: this.offsetX, y: this.offsetY },
                        e.util.degreesToRadians(-t.angle)
                      ),
                      a = 20,
                      h = new e.Color(this.color);
                    return (
                      t.width &&
                        t.height &&
                        ((n = 100 * i((Math.abs(o.x) + this.blur) / t.width, s) + a),
                        (r = 100 * i((Math.abs(o.y) + this.blur) / t.height, s) + a)),
                      t.flipX && (o.x *= -1),
                      t.flipY && (o.y *= -1),
                      '<filter id="SVGID_' +
                        this.id +
                        '" y="-' +
                        r +
                        '%" height="' +
                        (100 + 2 * r) +
                        '%" x="-' +
                        n +
                        '%" width="' +
                        (100 + 2 * n) +
                        '%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="' +
                        i(this.blur ? this.blur / 2 : 0, s) +
                        '"></feGaussianBlur>\n\t<feOffset dx="' +
                        i(o.x, s) +
                        '" dy="' +
                        i(o.y, s) +
                        '" result="oBlur" ></feOffset>\n\t<feFlood flood-color="' +
                        h.toRgb() +
                        '" flood-opacity="' +
                        h.getAlpha() +
                        '"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n'
                    );
                  },
                  toObject: function () {
                    if (this.includeDefaultValues)
                      return {
                        color: this.color,
                        blur: this.blur,
                        offsetX: this.offsetX,
                        offsetY: this.offsetY,
                        affectStroke: this.affectStroke,
                      };
                    var t = {},
                      i = e.Shadow.prototype;
                    return (
                      ["color", "blur", "offsetX", "offsetY", "affectStroke"].forEach(function (e) {
                        this[e] !== i[e] && (t[e] = this[e]);
                      }, this),
                      t
                    );
                  },
                })),
                (e.Shadow.reOffsetsAndBlur =
                  /(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/));
          })(e),
          (function () {
            "use strict";
            if (n.StaticCanvas) n.warn("fabric.StaticCanvas is already defined.");
            else {
              var t = n.util.object.extend,
                e = n.util.getElementOffset,
                i = n.util.removeFromArray,
                r = n.util.toFixed,
                s = n.util.transformPoint,
                o = n.util.invertTransform,
                a = n.util.getNodeCanvas,
                h = n.util.createCanvasElement,
                c = new Error("Could not initialize `canvas` element");
              (n.StaticCanvas = n.util.createClass(n.CommonMethods, {
                initialize: function (t, e) {
                  e || (e = {}),
                    (this.renderAndResetBound = this.renderAndReset.bind(this)),
                    (this.requestRenderAllBound = this.requestRenderAll.bind(this)),
                    this._initStatic(t, e);
                },
                backgroundColor: "",
                backgroundImage: null,
                overlayColor: "",
                overlayImage: null,
                includeDefaultValues: !0,
                stateful: !1,
                renderOnAddRemove: !0,
                clipTo: null,
                controlsAboveOverlay: !1,
                allowTouchScrolling: !1,
                imageSmoothingEnabled: !0,
                viewportTransform: n.iMatrix.concat(),
                backgroundVpt: !0,
                overlayVpt: !0,
                onBeforeScaleRotate: function () {},
                enableRetinaScaling: !0,
                vptCoords: {},
                skipOffscreen: !0,
                clipPath: void 0,
                _initStatic: function (t, e) {
                  var i = this.requestRenderAllBound;
                  (this._objects = []),
                    this._createLowerCanvas(t),
                    this._initOptions(e),
                    this._setImageSmoothing(),
                    this.interactive || this._initRetinaScaling(),
                    e.overlayImage && this.setOverlayImage(e.overlayImage, i),
                    e.backgroundImage && this.setBackgroundImage(e.backgroundImage, i),
                    e.backgroundColor && this.setBackgroundColor(e.backgroundColor, i),
                    e.overlayColor && this.setOverlayColor(e.overlayColor, i),
                    this.calcOffset();
                },
                _isRetinaScaling: function () {
                  return 1 !== n.devicePixelRatio && this.enableRetinaScaling;
                },
                getRetinaScaling: function () {
                  return this._isRetinaScaling() ? n.devicePixelRatio : 1;
                },
                _initRetinaScaling: function () {
                  this._isRetinaScaling() &&
                    (this.lowerCanvasEl.setAttribute("width", this.width * n.devicePixelRatio),
                    this.lowerCanvasEl.setAttribute("height", this.height * n.devicePixelRatio),
                    this.contextContainer.scale(n.devicePixelRatio, n.devicePixelRatio));
                },
                calcOffset: function () {
                  return (this._offset = e(this.lowerCanvasEl)), this;
                },
                setOverlayImage: function (t, e, i) {
                  return this.__setBgOverlayImage("overlayImage", t, e, i);
                },
                setBackgroundImage: function (t, e, i) {
                  return this.__setBgOverlayImage("backgroundImage", t, e, i);
                },
                setOverlayColor: function (t, e) {
                  return this.__setBgOverlayColor("overlayColor", t, e);
                },
                setBackgroundColor: function (t, e) {
                  return this.__setBgOverlayColor("backgroundColor", t, e);
                },
                _setImageSmoothing: function () {
                  var t = this.getContext();
                  (t.imageSmoothingEnabled =
                    t.imageSmoothingEnabled ||
                    t.webkitImageSmoothingEnabled ||
                    t.mozImageSmoothingEnabled ||
                    t.msImageSmoothingEnabled ||
                    t.oImageSmoothingEnabled),
                    (t.imageSmoothingEnabled = this.imageSmoothingEnabled);
                },
                __setBgOverlayImage: function (t, e, i, r) {
                  return (
                    "string" === typeof e
                      ? n.util.loadImage(
                          e,
                          function (e) {
                            if (e) {
                              var s = new n.Image(e, r);
                              (this[t] = s), (s.canvas = this);
                            }
                            i && i(e);
                          },
                          this,
                          r && r.crossOrigin
                        )
                      : (r && e.setOptions(r), (this[t] = e), e && (e.canvas = this), i && i(e)),
                    this
                  );
                },
                __setBgOverlayColor: function (t, e, i) {
                  return (this[t] = e), this._initGradient(e, t), this._initPattern(e, t, i), this;
                },
                _createCanvasElement: function () {
                  var t = h();
                  if (!t) throw c;
                  if ((t.style || (t.style = {}), "undefined" === typeof t.getContext)) throw c;
                  return t;
                },
                _initOptions: function (t) {
                  var e = this.lowerCanvasEl;
                  this._setOptions(t),
                    (this.width = this.width || parseInt(e.width, 10) || 0),
                    (this.height = this.height || parseInt(e.height, 10) || 0),
                    this.lowerCanvasEl.style &&
                      ((e.width = this.width),
                      (e.height = this.height),
                      (e.style.width = this.width + "px"),
                      (e.style.height = this.height + "px"),
                      (this.viewportTransform = this.viewportTransform.slice()));
                },
                _createLowerCanvas: function (t) {
                  t && t.getContext
                    ? (this.lowerCanvasEl = t)
                    : (this.lowerCanvasEl = n.util.getById(t) || this._createCanvasElement()),
                    n.util.addClass(this.lowerCanvasEl, "lower-canvas"),
                    this.interactive && this._applyCanvasStyle(this.lowerCanvasEl),
                    (this.contextContainer = this.lowerCanvasEl.getContext("2d"));
                },
                getWidth: function () {
                  return this.width;
                },
                getHeight: function () {
                  return this.height;
                },
                setWidth: function (t, e) {
                  return this.setDimensions({ width: t }, e);
                },
                setHeight: function (t, e) {
                  return this.setDimensions({ height: t }, e);
                },
                setDimensions: function (t, e) {
                  var i;
                  for (var n in ((e = e || {}), t))
                    (i = t[n]),
                      e.cssOnly ||
                        (this._setBackstoreDimension(n, t[n]),
                        (i += "px"),
                        (this.hasLostContext = !0)),
                      e.backstoreOnly || this._setCssDimension(n, i);
                  return (
                    this._isCurrentlyDrawing &&
                      this.freeDrawingBrush &&
                      this.freeDrawingBrush._setBrushStyles(),
                    this._initRetinaScaling(),
                    this._setImageSmoothing(),
                    this.calcOffset(),
                    e.cssOnly || this.requestRenderAll(),
                    this
                  );
                },
                _setBackstoreDimension: function (t, e) {
                  return (
                    (this.lowerCanvasEl[t] = e),
                    this.upperCanvasEl && (this.upperCanvasEl[t] = e),
                    this.cacheCanvasEl && (this.cacheCanvasEl[t] = e),
                    (this[t] = e),
                    this
                  );
                },
                _setCssDimension: function (t, e) {
                  return (
                    (this.lowerCanvasEl.style[t] = e),
                    this.upperCanvasEl && (this.upperCanvasEl.style[t] = e),
                    this.wrapperEl && (this.wrapperEl.style[t] = e),
                    this
                  );
                },
                getZoom: function () {
                  return this.viewportTransform[0];
                },
                setViewportTransform: function (t) {
                  var e,
                    i,
                    n,
                    r = this._activeObject,
                    s = !1,
                    o = !0;
                  for (this.viewportTransform = t, i = 0, n = this._objects.length; i < n; i++)
                    (e = this._objects[i]), e.group || e.setCoords(s, o);
                  return (
                    r && "activeSelection" === r.type && r.setCoords(s, o),
                    this.calcViewportBoundaries(),
                    this.renderOnAddRemove && this.requestRenderAll(),
                    this
                  );
                },
                zoomToPoint: function (t, e) {
                  var i = t,
                    n = this.viewportTransform.slice(0);
                  (t = s(t, o(this.viewportTransform))), (n[0] = e), (n[3] = e);
                  var r = s(t, n);
                  return (n[4] += i.x - r.x), (n[5] += i.y - r.y), this.setViewportTransform(n);
                },
                setZoom: function (t) {
                  return this.zoomToPoint(new n.Point(0, 0), t), this;
                },
                absolutePan: function (t) {
                  var e = this.viewportTransform.slice(0);
                  return (e[4] = -t.x), (e[5] = -t.y), this.setViewportTransform(e);
                },
                relativePan: function (t) {
                  return this.absolutePan(
                    new n.Point(-t.x - this.viewportTransform[4], -t.y - this.viewportTransform[5])
                  );
                },
                getElement: function () {
                  return this.lowerCanvasEl;
                },
                _onObjectAdded: function (t) {
                  this.stateful && t.setupState(),
                    t._set("canvas", this),
                    t.setCoords(),
                    this.fire("object:added", { target: t }),
                    t.fire("added");
                },
                _onObjectRemoved: function (t) {
                  this.fire("object:removed", { target: t }), t.fire("removed"), delete t.canvas;
                },
                clearContext: function (t) {
                  return t.clearRect(0, 0, this.width, this.height), this;
                },
                getContext: function () {
                  return this.contextContainer;
                },
                clear: function () {
                  return (
                    (this._objects.length = 0),
                    (this.backgroundImage = null),
                    (this.overlayImage = null),
                    (this.backgroundColor = ""),
                    (this.overlayColor = ""),
                    this._hasITextHandlers &&
                      (this.off("mouse:up", this._mouseUpITextHandler),
                      (this._iTextInstances = null),
                      (this._hasITextHandlers = !1)),
                    this.clearContext(this.contextContainer),
                    this.fire("canvas:cleared"),
                    this.renderOnAddRemove && this.requestRenderAll(),
                    this
                  );
                },
                renderAll: function () {
                  var t = this.contextContainer;
                  return this.renderCanvas(t, this._objects), this;
                },
                renderAndReset: function () {
                  (this.isRendering = 0), this.renderAll();
                },
                requestRenderAll: function () {
                  return (
                    this.isRendering ||
                      (this.isRendering = n.util.requestAnimFrame(this.renderAndResetBound)),
                    this
                  );
                },
                calcViewportBoundaries: function () {
                  var t = {},
                    e = this.width,
                    i = this.height,
                    r = o(this.viewportTransform);
                  return (
                    (t.tl = s({ x: 0, y: 0 }, r)),
                    (t.br = s({ x: e, y: i }, r)),
                    (t.tr = new n.Point(t.br.x, t.tl.y)),
                    (t.bl = new n.Point(t.tl.x, t.br.y)),
                    (this.vptCoords = t),
                    t
                  );
                },
                cancelRequestedRender: function () {
                  this.isRendering &&
                    (n.util.cancelAnimFrame(this.isRendering), (this.isRendering = 0));
                },
                renderCanvas: function (t, e) {
                  var i = this.viewportTransform,
                    r = this.clipPath;
                  this.cancelRequestedRender(),
                    this.calcViewportBoundaries(),
                    this.clearContext(t),
                    this.fire("before:render", { ctx: t }),
                    this.clipTo && n.util.clipContext(this, t),
                    this._renderBackground(t),
                    t.save(),
                    t.transform(i[0], i[1], i[2], i[3], i[4], i[5]),
                    this._renderObjects(t, e),
                    t.restore(),
                    !this.controlsAboveOverlay && this.interactive && this.drawControls(t),
                    this.clipTo && t.restore(),
                    r &&
                      ((r.canvas = this),
                      r.shouldCache(),
                      (r._transformDone = !0),
                      r.renderCache({ forClipping: !0 }),
                      this.drawClipPathOnCanvas(t)),
                    this._renderOverlay(t),
                    this.controlsAboveOverlay && this.interactive && this.drawControls(t),
                    this.fire("after:render", { ctx: t });
                },
                drawClipPathOnCanvas: function (t) {
                  var e = this.viewportTransform,
                    i = this.clipPath;
                  t.save(),
                    t.transform(e[0], e[1], e[2], e[3], e[4], e[5]),
                    (t.globalCompositeOperation = "destination-in"),
                    i.transform(t),
                    t.scale(1 / i.zoomX, 1 / i.zoomY),
                    t.drawImage(i._cacheCanvas, -i.cacheTranslationX, -i.cacheTranslationY),
                    t.restore();
                },
                _renderObjects: function (t, e) {
                  var i, n;
                  for (i = 0, n = e.length; i < n; ++i) e[i] && e[i].render(t);
                },
                _renderBackgroundOrOverlay: function (t, e) {
                  var i,
                    n = this[e + "Color"];
                  n &&
                    ((t.fillStyle = n.toLive ? n.toLive(t, this) : n),
                    t.fillRect(n.offsetX || 0, n.offsetY || 0, this.width, this.height)),
                    (n = this[e + "Image"]),
                    n &&
                      (this[e + "Vpt"] &&
                        ((i = this.viewportTransform),
                        t.save(),
                        t.transform(i[0], i[1], i[2], i[3], i[4], i[5])),
                      n.render(t),
                      this[e + "Vpt"] && t.restore());
                },
                _renderBackground: function (t) {
                  this._renderBackgroundOrOverlay(t, "background");
                },
                _renderOverlay: function (t) {
                  this._renderBackgroundOrOverlay(t, "overlay");
                },
                getCenter: function () {
                  return { top: this.height / 2, left: this.width / 2 };
                },
                centerObjectH: function (t) {
                  return this._centerObject(
                    t,
                    new n.Point(this.getCenter().left, t.getCenterPoint().y)
                  );
                },
                centerObjectV: function (t) {
                  return this._centerObject(
                    t,
                    new n.Point(t.getCenterPoint().x, this.getCenter().top)
                  );
                },
                centerObject: function (t) {
                  var e = this.getCenter();
                  return this._centerObject(t, new n.Point(e.left, e.top));
                },
                viewportCenterObject: function (t) {
                  var e = this.getVpCenter();
                  return this._centerObject(t, e);
                },
                viewportCenterObjectH: function (t) {
                  var e = this.getVpCenter();
                  return this._centerObject(t, new n.Point(e.x, t.getCenterPoint().y)), this;
                },
                viewportCenterObjectV: function (t) {
                  var e = this.getVpCenter();
                  return this._centerObject(t, new n.Point(t.getCenterPoint().x, e.y));
                },
                getVpCenter: function () {
                  var t = this.getCenter(),
                    e = o(this.viewportTransform);
                  return s({ x: t.left, y: t.top }, e);
                },
                _centerObject: function (t, e) {
                  return (
                    t.setPositionByOrigin(e, "center", "center"),
                    t.setCoords(),
                    this.renderOnAddRemove && this.requestRenderAll(),
                    this
                  );
                },
                toDatalessJSON: function (t) {
                  return this.toDatalessObject(t);
                },
                toObject: function (t) {
                  return this._toObjectMethod("toObject", t);
                },
                toDatalessObject: function (t) {
                  return this._toObjectMethod("toDatalessObject", t);
                },
                _toObjectMethod: function (e, i) {
                  var r = this.clipPath,
                    s = { version: n.version, objects: this._toObjects(e, i) };
                  return (
                    r && (s.clipPath = this._toObjectMethod(r, e, i)),
                    t(s, this.__serializeBgOverlay(e, i)),
                    n.util.populateWithProperties(this, s, i),
                    s
                  );
                },
                _toObjects: function (t, e) {
                  return this._objects
                    .filter(function (t) {
                      return !t.excludeFromExport;
                    })
                    .map(function (i) {
                      return this._toObject(i, t, e);
                    }, this);
                },
                _toObject: function (t, e, i) {
                  var n;
                  this.includeDefaultValues ||
                    ((n = t.includeDefaultValues), (t.includeDefaultValues = !1));
                  var r = t[e](i);
                  return this.includeDefaultValues || (t.includeDefaultValues = n), r;
                },
                __serializeBgOverlay: function (t, e) {
                  var i = {},
                    n = this.backgroundImage,
                    r = this.overlayImage;
                  return (
                    this.backgroundColor &&
                      (i.background = this.backgroundColor.toObject
                        ? this.backgroundColor.toObject(e)
                        : this.backgroundColor),
                    this.overlayColor &&
                      (i.overlay = this.overlayColor.toObject
                        ? this.overlayColor.toObject(e)
                        : this.overlayColor),
                    n && !n.excludeFromExport && (i.backgroundImage = this._toObject(n, t, e)),
                    r && !r.excludeFromExport && (i.overlayImage = this._toObject(r, t, e)),
                    i
                  );
                },
                svgViewportTransformation: !0,
                toSVG: function (t, e) {
                  t || (t = {}), (t.reviver = e);
                  var i = [];
                  return (
                    this._setSVGPreamble(i, t),
                    this._setSVGHeader(i, t),
                    this.clipPath &&
                      i.push('<g clip-path="url(#' + this.clipPath.clipPathId + ')" >\n'),
                    this._setSVGBgOverlayColor(i, "backgroundColor"),
                    this._setSVGBgOverlayImage(i, "backgroundImage", e),
                    this._setSVGObjects(i, e),
                    this.clipPath && i.push("</g>\n"),
                    this._setSVGBgOverlayColor(i, "overlayColor"),
                    this._setSVGBgOverlayImage(i, "overlayImage", e),
                    i.push("</svg>"),
                    i.join("")
                  );
                },
                _setSVGPreamble: function (t, e) {
                  e.suppressPreamble ||
                    t.push(
                      '<?xml version="1.0" encoding="',
                      e.encoding || "UTF-8",
                      '" standalone="no" ?>\n',
                      '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',
                      '"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n'
                    );
                },
                _setSVGHeader: function (t, e) {
                  var i,
                    s = e.width || this.width,
                    o = e.height || this.height,
                    a = 'viewBox="0 0 ' + this.width + " " + this.height + '" ',
                    h = n.Object.NUM_FRACTION_DIGITS;
                  e.viewBox
                    ? (a =
                        'viewBox="' +
                        e.viewBox.x +
                        " " +
                        e.viewBox.y +
                        " " +
                        e.viewBox.width +
                        " " +
                        e.viewBox.height +
                        '" ')
                    : this.svgViewportTransformation &&
                      ((i = this.viewportTransform),
                      (a =
                        'viewBox="' +
                        r(-i[4] / i[0], h) +
                        " " +
                        r(-i[5] / i[3], h) +
                        " " +
                        r(this.width / i[0], h) +
                        " " +
                        r(this.height / i[3], h) +
                        '" ')),
                    t.push(
                      "<svg ",
                      'xmlns="http://www.w3.org/2000/svg" ',
                      'xmlns:xlink="http://www.w3.org/1999/xlink" ',
                      'version="1.1" ',
                      'width="',
                      s,
                      '" ',
                      'height="',
                      o,
                      '" ',
                      a,
                      'xml:space="preserve">\n',
                      "<desc>Created with Fabric.js ",
                      n.version,
                      "</desc>\n",
                      "<defs>\n",
                      this.createSVGFontFacesMarkup(),
                      this.createSVGRefElementsMarkup(),
                      this.createSVGClipPathMarkup(e),
                      "</defs>\n"
                    );
                },
                createSVGClipPathMarkup: function (t) {
                  var e = this.clipPath;
                  return e
                    ? ((e.clipPathId = "CLIPPATH_" + n.Object.__uid++),
                      '<clipPath id="' +
                        e.clipPathId +
                        '" >\n' +
                        this.clipPath.toClipPathSVG(t.reviver) +
                        "</clipPath>\n")
                    : "";
                },
                createSVGRefElementsMarkup: function () {
                  var t = this,
                    e = ["backgroundColor", "overlayColor"].map(function (e) {
                      var i = t[e];
                      if (i && i.toLive) return i.toSVG(t, !1);
                    });
                  return e.join("");
                },
                createSVGFontFacesMarkup: function () {
                  var t,
                    e,
                    i,
                    r,
                    s,
                    o,
                    a,
                    h,
                    c,
                    l = "",
                    u = {},
                    f = n.fontPaths,
                    d = this._objects;
                  for (h = 0, c = d.length; h < c; h++)
                    if (
                      ((t = d[h]),
                      (e = t.fontFamily),
                      -1 !== t.type.indexOf("text") && !u[e] && f[e] && ((u[e] = !0), t.styles))
                    )
                      for (s in ((i = t.styles), i))
                        for (a in ((r = i[s]), r))
                          (o = r[a]), (e = o.fontFamily), !u[e] && f[e] && (u[e] = !0);
                  for (var g in u)
                    l += [
                      "\t\t@font-face {\n",
                      "\t\t\tfont-family: '",
                      g,
                      "';\n",
                      "\t\t\tsrc: url('",
                      f[g],
                      "');\n",
                      "\t\t}\n",
                    ].join("");
                  return (
                    l &&
                      (l = [
                        '\t<style type="text/css">',
                        "<![CDATA[\n",
                        l,
                        "]]>",
                        "</style>\n",
                      ].join("")),
                    l
                  );
                },
                _setSVGObjects: function (t, e) {
                  var i,
                    n,
                    r,
                    s = this._objects;
                  for (n = 0, r = s.length; n < r; n++)
                    (i = s[n]), i.excludeFromExport || this._setSVGObject(t, i, e);
                },
                _setSVGObject: function (t, e, i) {
                  t.push(e.toSVG(i));
                },
                _setSVGBgOverlayImage: function (t, e, i) {
                  this[e] &&
                    !this[e].excludeFromExport &&
                    this[e].toSVG &&
                    t.push(this[e].toSVG(i));
                },
                _setSVGBgOverlayColor: function (t, e) {
                  var i = this[e],
                    n = this.viewportTransform,
                    r = this.width / n[0],
                    s = this.height / n[3];
                  if (i)
                    if (i.toLive) {
                      var o = i.repeat;
                      t.push(
                        '<rect transform="translate(',
                        r / 2,
                        ",",
                        s / 2,
                        ')"',
                        ' x="',
                        i.offsetX - r / 2,
                        '" y="',
                        i.offsetY - s / 2,
                        '" ',
                        'width="',
                        "repeat-y" === o || "no-repeat" === o ? i.source.width : r,
                        '" height="',
                        "repeat-x" === o || "no-repeat" === o ? i.source.height : s,
                        '" fill="url(#SVGID_' + i.id + ')"',
                        "></rect>\n"
                      );
                    } else
                      t.push(
                        '<rect x="0" y="0" width="100%" height="100%" ',
                        'fill="',
                        this[e],
                        '"',
                        "></rect>\n"
                      );
                },
                sendToBack: function (t) {
                  if (!t) return this;
                  var e,
                    n,
                    r,
                    s = this._activeObject;
                  if (t === s && "activeSelection" === t.type)
                    for (r = s._objects, e = r.length; e--; )
                      (n = r[e]), i(this._objects, n), this._objects.unshift(n);
                  else i(this._objects, t), this._objects.unshift(t);
                  return this.renderOnAddRemove && this.requestRenderAll(), this;
                },
                bringToFront: function (t) {
                  if (!t) return this;
                  var e,
                    n,
                    r,
                    s = this._activeObject;
                  if (t === s && "activeSelection" === t.type)
                    for (r = s._objects, e = 0; e < r.length; e++)
                      (n = r[e]), i(this._objects, n), this._objects.push(n);
                  else i(this._objects, t), this._objects.push(t);
                  return this.renderOnAddRemove && this.requestRenderAll(), this;
                },
                sendBackwards: function (t, e) {
                  if (!t) return this;
                  var n,
                    r,
                    s,
                    o,
                    a,
                    h = this._activeObject,
                    c = 0;
                  if (t === h && "activeSelection" === t.type)
                    for (a = h._objects, n = 0; n < a.length; n++)
                      (r = a[n]),
                        (s = this._objects.indexOf(r)),
                        s > 0 + c &&
                          ((o = s - 1), i(this._objects, r), this._objects.splice(o, 0, r)),
                        c++;
                  else
                    (s = this._objects.indexOf(t)),
                      0 !== s &&
                        ((o = this._findNewLowerIndex(t, s, e)),
                        i(this._objects, t),
                        this._objects.splice(o, 0, t));
                  return this.renderOnAddRemove && this.requestRenderAll(), this;
                },
                _findNewLowerIndex: function (t, e, i) {
                  var n, r;
                  if (i)
                    for (n = e, r = e - 1; r >= 0; --r) {
                      var s =
                        t.intersectsWithObject(this._objects[r]) ||
                        t.isContainedWithinObject(this._objects[r]) ||
                        this._objects[r].isContainedWithinObject(t);
                      if (s) {
                        n = r;
                        break;
                      }
                    }
                  else n = e - 1;
                  return n;
                },
                bringForward: function (t, e) {
                  if (!t) return this;
                  var n,
                    r,
                    s,
                    o,
                    a,
                    h = this._activeObject,
                    c = 0;
                  if (t === h && "activeSelection" === t.type)
                    for (a = h._objects, n = a.length; n--; )
                      (r = a[n]),
                        (s = this._objects.indexOf(r)),
                        s < this._objects.length - 1 - c &&
                          ((o = s + 1), i(this._objects, r), this._objects.splice(o, 0, r)),
                        c++;
                  else
                    (s = this._objects.indexOf(t)),
                      s !== this._objects.length - 1 &&
                        ((o = this._findNewUpperIndex(t, s, e)),
                        i(this._objects, t),
                        this._objects.splice(o, 0, t));
                  return this.renderOnAddRemove && this.requestRenderAll(), this;
                },
                _findNewUpperIndex: function (t, e, i) {
                  var n, r, s;
                  if (i)
                    for (n = e, r = e + 1, s = this._objects.length; r < s; ++r) {
                      var o =
                        t.intersectsWithObject(this._objects[r]) ||
                        t.isContainedWithinObject(this._objects[r]) ||
                        this._objects[r].isContainedWithinObject(t);
                      if (o) {
                        n = r;
                        break;
                      }
                    }
                  else n = e + 1;
                  return n;
                },
                moveTo: function (t, e) {
                  return (
                    i(this._objects, t),
                    this._objects.splice(e, 0, t),
                    this.renderOnAddRemove && this.requestRenderAll()
                  );
                },
                dispose: function () {
                  return (
                    this.isRendering &&
                      (n.util.cancelAnimFrame(this.isRendering), (this.isRendering = 0)),
                    this.forEachObject(function (t) {
                      t.dispose && t.dispose();
                    }),
                    (this._objects = []),
                    this.backgroundImage &&
                      this.backgroundImage.dispose &&
                      this.backgroundImage.dispose(),
                    (this.backgroundImage = null),
                    this.overlayImage && this.overlayImage.dispose && this.overlayImage.dispose(),
                    (this.overlayImage = null),
                    (this._iTextInstances = null),
                    (this.contextContainer = null),
                    n.util.cleanUpJsdomNode(this.lowerCanvasEl),
                    (this.lowerCanvasEl = void 0),
                    this
                  );
                },
                toString: function () {
                  return (
                    "#<fabric.Canvas (" +
                    this.complexity() +
                    "): { objects: " +
                    this._objects.length +
                    " }>"
                  );
                },
              })),
                t(n.StaticCanvas.prototype, n.Observable),
                t(n.StaticCanvas.prototype, n.Collection),
                t(n.StaticCanvas.prototype, n.DataURLExporter),
                t(n.StaticCanvas, {
                  EMPTY_JSON: '{"objects": [], "background": "white"}',
                  supports: function (t) {
                    var e = h();
                    if (!e || !e.getContext) return null;
                    var i = e.getContext("2d");
                    if (!i) return null;
                    switch (t) {
                      case "setLineDash":
                        return "undefined" !== typeof i.setLineDash;
                      default:
                        return null;
                    }
                  },
                }),
                (n.StaticCanvas.prototype.toJSON = n.StaticCanvas.prototype.toObject),
                n.isLikelyNode &&
                  ((n.StaticCanvas.prototype.createPNGStream = function () {
                    var t = a(this.lowerCanvasEl);
                    return t && t.createPNGStream();
                  }),
                  (n.StaticCanvas.prototype.createJPEGStream = function (t) {
                    var e = a(this.lowerCanvasEl);
                    return e && e.createJPEGStream(t);
                  }));
            }
          })(),
          (n.BaseBrush = n.util.createClass({
            color: "rgb(0, 0, 0)",
            width: 1,
            shadow: null,
            strokeLineCap: "round",
            strokeLineJoin: "round",
            strokeMiterLimit: 10,
            strokeDashArray: null,
            setShadow: function (t) {
              return (this.shadow = new n.Shadow(t)), this;
            },
            _setBrushStyles: function () {
              var t = this.canvas.contextTop;
              (t.strokeStyle = this.color),
                (t.lineWidth = this.width),
                (t.lineCap = this.strokeLineCap),
                (t.miterLimit = this.strokeMiterLimit),
                (t.lineJoin = this.strokeLineJoin),
                n.StaticCanvas.supports("setLineDash") && t.setLineDash(this.strokeDashArray || []);
            },
            _saveAndTransform: function (t) {
              var e = this.canvas.viewportTransform;
              t.save(), t.transform(e[0], e[1], e[2], e[3], e[4], e[5]);
            },
            _setShadow: function () {
              if (this.shadow) {
                var t = this.canvas.contextTop,
                  e = this.canvas.getZoom();
                (t.shadowColor = this.shadow.color),
                  (t.shadowBlur = this.shadow.blur * e),
                  (t.shadowOffsetX = this.shadow.offsetX * e),
                  (t.shadowOffsetY = this.shadow.offsetY * e);
              }
            },
            _resetShadow: function () {
              var t = this.canvas.contextTop;
              (t.shadowColor = ""), (t.shadowBlur = t.shadowOffsetX = t.shadowOffsetY = 0);
            },
          })),
          (function () {
            n.PencilBrush = n.util.createClass(n.BaseBrush, {
              initialize: function (t) {
                (this.canvas = t), (this._points = []);
              },
              _drawSegment: function (t, e, i) {
                var n = e.midPointFrom(i);
                return t.quadraticCurveTo(e.x, e.y, n.x, n.y), n;
              },
              onMouseDown: function (t) {
                this._prepareForDrawing(t), this._captureDrawingPath(t), this._render();
              },
              onMouseMove: function (t) {
                if (this._captureDrawingPath(t) && this._points.length > 1)
                  if (this.needsFullRender)
                    this.canvas.clearContext(this.canvas.contextTop), this._render();
                  else {
                    var e = this._points,
                      i = e.length,
                      n = this.canvas.contextTop;
                    this._saveAndTransform(n),
                      this.oldEnd && (n.beginPath(), n.moveTo(this.oldEnd.x, this.oldEnd.y)),
                      (this.oldEnd = this._drawSegment(n, e[i - 2], e[i - 1], !0)),
                      n.stroke(),
                      n.restore();
                  }
              },
              onMouseUp: function () {
                (this.oldEnd = void 0), this._finalizeAndAddPath();
              },
              _prepareForDrawing: function (t) {
                var e = new n.Point(t.x, t.y);
                this._reset(), this._addPoint(e), this.canvas.contextTop.moveTo(e.x, e.y);
              },
              _addPoint: function (t) {
                return (
                  !(this._points.length > 1 && t.eq(this._points[this._points.length - 1])) &&
                  (this._points.push(t), !0)
                );
              },
              _reset: function () {
                (this._points.length = 0), this._setBrushStyles();
                var t = new n.Color(this.color);
                (this.needsFullRender = t.getAlpha() < 1), this._setShadow();
              },
              _captureDrawingPath: function (t) {
                var e = new n.Point(t.x, t.y);
                return this._addPoint(e);
              },
              _render: function () {
                var t,
                  e,
                  i = this.canvas.contextTop,
                  r = this._points[0],
                  s = this._points[1];
                if (
                  (this._saveAndTransform(i),
                  i.beginPath(),
                  2 === this._points.length && r.x === s.x && r.y === s.y)
                ) {
                  var o = this.width / 1e3;
                  (r = new n.Point(r.x, r.y)), (s = new n.Point(s.x, s.y)), (r.x -= o), (s.x += o);
                }
                for (i.moveTo(r.x, r.y), t = 1, e = this._points.length; t < e; t++)
                  this._drawSegment(i, r, s), (r = this._points[t]), (s = this._points[t + 1]);
                i.lineTo(r.x, r.y), i.stroke(), i.restore();
              },
              convertPointsToSVGPath: function (t) {
                var e,
                  i = [],
                  r = this.width / 1e3,
                  s = new n.Point(t[0].x, t[0].y),
                  o = new n.Point(t[1].x, t[1].y),
                  a = t.length,
                  h = 1,
                  c = 1,
                  l = a > 2;
                for (
                  l &&
                    ((h = t[2].x < o.x ? -1 : t[2].x === o.x ? 0 : 1),
                    (c = t[2].y < o.y ? -1 : t[2].y === o.y ? 0 : 1)),
                    i.push("M ", s.x - h * r, " ", s.y - c * r, " "),
                    e = 1;
                  e < a;
                  e++
                ) {
                  if (!s.eq(o)) {
                    var u = s.midPointFrom(o);
                    i.push("Q ", s.x, " ", s.y, " ", u.x, " ", u.y, " ");
                  }
                  (s = t[e]), e + 1 < t.length && (o = t[e + 1]);
                }
                return (
                  l &&
                    ((h = s.x > t[e - 2].x ? 1 : s.x === t[e - 2].x ? 0 : -1),
                    (c = s.y > t[e - 2].y ? 1 : s.y === t[e - 2].y ? 0 : -1)),
                  i.push("L ", s.x + h * r, " ", s.y + c * r),
                  i
                );
              },
              createPath: function (t) {
                var e = new n.Path(t, {
                    fill: null,
                    stroke: this.color,
                    strokeWidth: this.width,
                    strokeLineCap: this.strokeLineCap,
                    strokeMiterLimit: this.strokeMiterLimit,
                    strokeLineJoin: this.strokeLineJoin,
                    strokeDashArray: this.strokeDashArray,
                  }),
                  i = new n.Point(e.left + e.width / 2, e.top + e.height / 2);
                return (
                  (i = e.translateToGivenOrigin(i, "center", "center", e.originX, e.originY)),
                  (e.top = i.y),
                  (e.left = i.x),
                  this.shadow && ((this.shadow.affectStroke = !0), e.setShadow(this.shadow)),
                  e
                );
              },
              _finalizeAndAddPath: function () {
                var t = this.canvas.contextTop;
                t.closePath();
                var e = this.convertPointsToSVGPath(this._points).join("");
                if ("M 0 0 Q 0 0 0 0 L 0 0" !== e) {
                  var i = this.createPath(e);
                  this.canvas.clearContext(this.canvas.contextTop),
                    this.canvas.add(i),
                    this.canvas.renderAll(),
                    i.setCoords(),
                    this._resetShadow(),
                    this.canvas.fire("path:created", { path: i });
                } else this.canvas.requestRenderAll();
              },
            });
          })(),
          (n.CircleBrush = n.util.createClass(n.BaseBrush, {
            width: 10,
            initialize: function (t) {
              (this.canvas = t), (this.points = []);
            },
            drawDot: function (t) {
              var e = this.addPoint(t),
                i = this.canvas.contextTop;
              this._saveAndTransform(i),
                (i.fillStyle = e.fill),
                i.beginPath(),
                i.arc(e.x, e.y, e.radius, 0, 2 * Math.PI, !1),
                i.closePath(),
                i.fill(),
                i.restore();
            },
            onMouseDown: function (t) {
              (this.points.length = 0),
                this.canvas.clearContext(this.canvas.contextTop),
                this._setShadow(),
                this.drawDot(t);
            },
            _render: function () {
              var t,
                e,
                i,
                n = this.canvas.contextTop,
                r = this.points;
              for (this._saveAndTransform(n), t = 0, e = r.length; t < e; t++)
                (i = r[t]),
                  (n.fillStyle = i.fill),
                  n.beginPath(),
                  n.arc(i.x, i.y, i.radius, 0, 2 * Math.PI, !1),
                  n.closePath(),
                  n.fill();
              n.restore();
            },
            onMouseMove: function (t) {
              this.drawDot(t);
            },
            onMouseUp: function () {
              var t,
                e,
                i = this.canvas.renderOnAddRemove;
              this.canvas.renderOnAddRemove = !1;
              var r = [];
              for (t = 0, e = this.points.length; t < e; t++) {
                var s = this.points[t],
                  o = new n.Circle({
                    radius: s.radius,
                    left: s.x,
                    top: s.y,
                    originX: "center",
                    originY: "center",
                    fill: s.fill,
                  });
                this.shadow && o.setShadow(this.shadow), r.push(o);
              }
              var a = new n.Group(r);
              (a.canvas = this.canvas),
                this.canvas.add(a),
                this.canvas.fire("path:created", { path: a }),
                this.canvas.clearContext(this.canvas.contextTop),
                this._resetShadow(),
                (this.canvas.renderOnAddRemove = i),
                this.canvas.requestRenderAll();
            },
            addPoint: function (t) {
              var e = new n.Point(t.x, t.y),
                i = n.util.getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,
                r = new n.Color(this.color).setAlpha(n.util.getRandomInt(0, 100) / 100).toRgba();
              return (e.radius = i), (e.fill = r), this.points.push(e), e;
            },
          })),
          (n.SprayBrush = n.util.createClass(n.BaseBrush, {
            width: 10,
            density: 20,
            dotWidth: 1,
            dotWidthVariance: 1,
            randomOpacity: !1,
            optimizeOverlapping: !0,
            initialize: function (t) {
              (this.canvas = t), (this.sprayChunks = []);
            },
            onMouseDown: function (t) {
              (this.sprayChunks.length = 0),
                this.canvas.clearContext(this.canvas.contextTop),
                this._setShadow(),
                this.addSprayChunk(t),
                this.render(this.sprayChunkPoints);
            },
            onMouseMove: function (t) {
              this.addSprayChunk(t), this.render(this.sprayChunkPoints);
            },
            onMouseUp: function () {
              var t = this.canvas.renderOnAddRemove;
              this.canvas.renderOnAddRemove = !1;
              for (var e = [], i = 0, r = this.sprayChunks.length; i < r; i++)
                for (var s = this.sprayChunks[i], o = 0, a = s.length; o < a; o++) {
                  var h = new n.Rect({
                    width: s[o].width,
                    height: s[o].width,
                    left: s[o].x + 1,
                    top: s[o].y + 1,
                    originX: "center",
                    originY: "center",
                    fill: this.color,
                  });
                  e.push(h);
                }
              this.optimizeOverlapping && (e = this._getOptimizedRects(e));
              var c = new n.Group(e);
              this.shadow && c.setShadow(this.shadow),
                this.canvas.add(c),
                this.canvas.fire("path:created", { path: c }),
                this.canvas.clearContext(this.canvas.contextTop),
                this._resetShadow(),
                (this.canvas.renderOnAddRemove = t),
                this.canvas.requestRenderAll();
            },
            _getOptimizedRects: function (t) {
              var e,
                i,
                n,
                r = {};
              for (i = 0, n = t.length; i < n; i++)
                (e = t[i].left + "" + t[i].top), r[e] || (r[e] = t[i]);
              var s = [];
              for (e in r) s.push(r[e]);
              return s;
            },
            render: function (t) {
              var e,
                i,
                n = this.canvas.contextTop;
              for (
                n.fillStyle = this.color, this._saveAndTransform(n), e = 0, i = t.length;
                e < i;
                e++
              ) {
                var r = t[e];
                "undefined" !== typeof r.opacity && (n.globalAlpha = r.opacity),
                  n.fillRect(r.x, r.y, r.width, r.width);
              }
              n.restore();
            },
            _render: function () {
              var t,
                e,
                i = this.canvas.contextTop;
              for (
                i.fillStyle = this.color,
                  this._saveAndTransform(i),
                  t = 0,
                  e = this.sprayChunks.length;
                t < e;
                t++
              )
                this.render(this.sprayChunks[t]);
              i.restore();
            },
            addSprayChunk: function (t) {
              this.sprayChunkPoints = [];
              var e,
                i,
                r,
                s,
                o = this.width / 2;
              for (s = 0; s < this.density; s++) {
                (e = n.util.getRandomInt(t.x - o, t.x + o)),
                  (i = n.util.getRandomInt(t.y - o, t.y + o)),
                  (r = this.dotWidthVariance
                    ? n.util.getRandomInt(
                        Math.max(1, this.dotWidth - this.dotWidthVariance),
                        this.dotWidth + this.dotWidthVariance
                      )
                    : this.dotWidth);
                var a = new n.Point(e, i);
                (a.width = r),
                  this.randomOpacity && (a.opacity = n.util.getRandomInt(0, 100) / 100),
                  this.sprayChunkPoints.push(a);
              }
              this.sprayChunks.push(this.sprayChunkPoints);
            },
          })),
          (n.PatternBrush = n.util.createClass(n.PencilBrush, {
            getPatternSrc: function () {
              var t = 20,
                e = 5,
                i = n.util.createCanvasElement(),
                r = i.getContext("2d");
              return (
                (i.width = i.height = t + e),
                (r.fillStyle = this.color),
                r.beginPath(),
                r.arc(t / 2, t / 2, t / 2, 0, 2 * Math.PI, !1),
                r.closePath(),
                r.fill(),
                i
              );
            },
            getPatternSrcFunction: function () {
              return String(this.getPatternSrc).replace("this.color", '"' + this.color + '"');
            },
            getPattern: function () {
              return this.canvas.contextTop.createPattern(
                this.source || this.getPatternSrc(),
                "repeat"
              );
            },
            _setBrushStyles: function () {
              this.callSuper("_setBrushStyles"),
                (this.canvas.contextTop.strokeStyle = this.getPattern());
            },
            createPath: function (t) {
              var e = this.callSuper("createPath", t),
                i = e._getLeftTopCoords().scalarAdd(e.strokeWidth / 2);
              return (
                (e.stroke = new n.Pattern({
                  source: this.source || this.getPatternSrcFunction(),
                  offsetX: -i.x,
                  offsetY: -i.y,
                })),
                e
              );
            },
          })),
          (function () {
            var t = n.util.getPointer,
              e = n.util.degreesToRadians,
              i = n.util.radiansToDegrees,
              r = Math.atan2,
              s = Math.abs,
              o = n.StaticCanvas.supports("setLineDash"),
              a = 0.5;
            for (var h in ((n.Canvas = n.util.createClass(n.StaticCanvas, {
              initialize: function (t, e) {
                e || (e = {}),
                  (this.renderAndResetBound = this.renderAndReset.bind(this)),
                  (this.requestRenderAllBound = this.requestRenderAll.bind(this)),
                  this._initStatic(t, e),
                  this._initInteractive(),
                  this._createCacheCanvas();
              },
              uniScaleTransform: !1,
              uniScaleKey: "shiftKey",
              centeredScaling: !1,
              centeredRotation: !1,
              centeredKey: "altKey",
              altActionKey: "shiftKey",
              interactive: !0,
              selection: !0,
              selectionKey: "shiftKey",
              altSelectionKey: null,
              selectionColor: "rgba(100, 100, 255, 0.3)",
              selectionDashArray: [],
              selectionBorderColor: "rgba(255, 255, 255, 0.3)",
              selectionLineWidth: 1,
              selectionFullyContained: !1,
              hoverCursor: "move",
              moveCursor: "move",
              defaultCursor: "default",
              freeDrawingCursor: "crosshair",
              rotationCursor: "crosshair",
              notAllowedCursor: "not-allowed",
              containerClass: "canvas-container",
              perPixelTargetFind: !1,
              targetFindTolerance: 0,
              skipTargetFind: !1,
              isDrawingMode: !1,
              preserveObjectStacking: !1,
              snapAngle: 0,
              snapThreshold: null,
              stopContextMenu: !1,
              fireRightClick: !1,
              fireMiddleClick: !1,
              _initInteractive: function () {
                (this._currentTransform = null),
                  (this._groupSelector = null),
                  this._initWrapperElement(),
                  this._createUpperCanvas(),
                  this._initEventListeners(),
                  this._initRetinaScaling(),
                  (this.freeDrawingBrush = n.PencilBrush && new n.PencilBrush(this)),
                  this.calcOffset();
              },
              _chooseObjectsToRender: function () {
                var t,
                  e,
                  i,
                  n = this.getActiveObjects();
                if (n.length > 0 && !this.preserveObjectStacking) {
                  (e = []), (i = []);
                  for (var r = 0, s = this._objects.length; r < s; r++)
                    (t = this._objects[r]), -1 === n.indexOf(t) ? e.push(t) : i.push(t);
                  n.length > 1 && (this._activeObject._objects = i), e.push.apply(e, i);
                } else e = this._objects;
                return e;
              },
              renderAll: function () {
                !this.contextTopDirty ||
                  this._groupSelector ||
                  this.isDrawingMode ||
                  (this.clearContext(this.contextTop), (this.contextTopDirty = !1)),
                  this.hasLostContext && this.renderTopLayer(this.contextTop);
                var t = this.contextContainer;
                return this.renderCanvas(t, this._chooseObjectsToRender()), this;
              },
              renderTopLayer: function (t) {
                t.save(),
                  this.isDrawingMode &&
                    this._isCurrentlyDrawing &&
                    (this.freeDrawingBrush && this.freeDrawingBrush._render(),
                    (this.contextTopDirty = !0)),
                  this.selection &&
                    this._groupSelector &&
                    (this._drawSelection(t), (this.contextTopDirty = !0)),
                  t.restore();
              },
              renderTop: function () {
                var t = this.contextTop;
                return (
                  this.clearContext(t), this.renderTopLayer(t), this.fire("after:render"), this
                );
              },
              _resetCurrentTransform: function () {
                var t = this._currentTransform;
                t.target.set({
                  scaleX: t.original.scaleX,
                  scaleY: t.original.scaleY,
                  skewX: t.original.skewX,
                  skewY: t.original.skewY,
                  left: t.original.left,
                  top: t.original.top,
                }),
                  this._shouldCenterTransform(t.target)
                    ? ("center" !== t.originX &&
                        ("right" === t.originX ? (t.mouseXSign = -1) : (t.mouseXSign = 1)),
                      "center" !== t.originY &&
                        ("bottom" === t.originY ? (t.mouseYSign = -1) : (t.mouseYSign = 1)),
                      (t.originX = "center"),
                      (t.originY = "center"))
                    : ((t.originX = t.original.originX), (t.originY = t.original.originY));
              },
              containsPoint: function (t, e, i) {
                var n,
                  r = !0,
                  s = i || this.getPointer(t, r);
                return (
                  (n =
                    e.group && e.group === this._activeObject && "activeSelection" === e.group.type
                      ? this._normalizePointer(e.group, s)
                      : { x: s.x, y: s.y }),
                  e.containsPoint(n) || e._findTargetCorner(s)
                );
              },
              _normalizePointer: function (t, e) {
                var i = t.calcTransformMatrix(),
                  r = n.util.invertTransform(i),
                  s = this.restorePointerVpt(e);
                return n.util.transformPoint(s, r);
              },
              isTargetTransparent: function (t, e, i) {
                if (t.shouldCache() && t._cacheCanvas && t !== this._activeObject) {
                  var r = this._normalizePointer(t, { x: e, y: i }),
                    s = Math.max(t.cacheTranslationX + r.x * t.zoomX, 0),
                    o = Math.max(t.cacheTranslationY + r.y * t.zoomY, 0),
                    a = n.util.isTransparent(
                      t._cacheContext,
                      Math.round(s),
                      Math.round(o),
                      this.targetFindTolerance
                    );
                  return a;
                }
                var h = this.contextCache,
                  c = t.selectionBackgroundColor,
                  l = this.viewportTransform;
                (t.selectionBackgroundColor = ""),
                  this.clearContext(h),
                  h.save(),
                  h.transform(l[0], l[1], l[2], l[3], l[4], l[5]),
                  t.render(h),
                  h.restore(),
                  t === this._activeObject &&
                    t._renderControls(
                      h,
                      { hasBorders: !1, transparentCorners: !1 },
                      { hasBorders: !1 }
                    ),
                  (t.selectionBackgroundColor = c);
                a = n.util.isTransparent(h, e, i, this.targetFindTolerance);
                return a;
              },
              _isSelectionKeyPressed: function (t) {
                var e = !1;
                return (
                  (e =
                    "[object Array]" === Object.prototype.toString.call(this.selectionKey)
                      ? !!this.selectionKey.find(function (e) {
                          return !0 === t[e];
                        })
                      : t[this.selectionKey]),
                  e
                );
              },
              _shouldClearSelection: function (t, e) {
                var i = this.getActiveObjects(),
                  n = this._activeObject;
                return (
                  !e ||
                  (e &&
                    n &&
                    i.length > 1 &&
                    -1 === i.indexOf(e) &&
                    n !== e &&
                    !this._isSelectionKeyPressed(t)) ||
                  (e && !e.evented) ||
                  (e && !e.selectable && n && n !== e)
                );
              },
              _shouldCenterTransform: function (t) {
                if (t) {
                  var e,
                    i = this._currentTransform;
                  return (
                    "scale" === i.action || "scaleX" === i.action || "scaleY" === i.action
                      ? (e = this.centeredScaling || t.centeredScaling)
                      : "rotate" === i.action && (e = this.centeredRotation || t.centeredRotation),
                    e ? !i.altKey : i.altKey
                  );
                }
              },
              _getOriginFromCorner: function (t, e) {
                var i = { x: t.originX, y: t.originY };
                return (
                  "ml" === e || "tl" === e || "bl" === e
                    ? (i.x = "right")
                    : ("mr" !== e && "tr" !== e && "br" !== e) || (i.x = "left"),
                  "tl" === e || "mt" === e || "tr" === e
                    ? (i.y = "bottom")
                    : ("bl" !== e && "mb" !== e && "br" !== e) || (i.y = "top"),
                  i
                );
              },
              _getActionFromCorner: function (t, e, i) {
                if (!e || !t) return "drag";
                switch (e) {
                  case "mtr":
                    return "rotate";
                  case "ml":
                  case "mr":
                    return i[this.altActionKey] ? "skewY" : "scaleX";
                  case "mt":
                  case "mb":
                    return i[this.altActionKey] ? "skewX" : "scaleY";
                  default:
                    return "scale";
                }
              },
              _setupCurrentTransform: function (t, i, r) {
                if (i) {
                  var s = this.getPointer(t),
                    o = i._findTargetCorner(this.getPointer(t, !0)),
                    a = this._getActionFromCorner(r, o, t, i),
                    h = this._getOriginFromCorner(i, o);
                  (this._currentTransform = {
                    target: i,
                    action: a,
                    corner: o,
                    scaleX: i.scaleX,
                    scaleY: i.scaleY,
                    skewX: i.skewX,
                    skewY: i.skewY,
                    offsetX: s.x - i.left,
                    offsetY: s.y - i.top,
                    originX: h.x,
                    originY: h.y,
                    ex: s.x,
                    ey: s.y,
                    lastX: s.x,
                    lastY: s.y,
                    theta: e(i.angle),
                    width: i.width * i.scaleX,
                    mouseXSign: 1,
                    mouseYSign: 1,
                    shiftKey: t.shiftKey,
                    altKey: t[this.centeredKey],
                    original: n.util.saveObjectTransform(i),
                  }),
                    (this._currentTransform.original.originX = h.x),
                    (this._currentTransform.original.originY = h.y),
                    this._resetCurrentTransform(),
                    this._beforeTransform(t);
                }
              },
              _translateObject: function (t, e) {
                var i = this._currentTransform,
                  n = i.target,
                  r = t - i.offsetX,
                  s = e - i.offsetY,
                  o = !n.get("lockMovementX") && n.left !== r,
                  a = !n.get("lockMovementY") && n.top !== s;
                return o && n.set("left", r), a && n.set("top", s), o || a;
              },
              _changeSkewTransformOrigin: function (t, e, i) {
                var n = "originX",
                  r = { 0: "center" },
                  s = e.target.skewX,
                  o = "left",
                  a = "right",
                  h = "mt" === e.corner || "ml" === e.corner ? 1 : -1,
                  c = 1;
                (t = t > 0 ? 1 : -1),
                  "y" === i && ((s = e.target.skewY), (o = "top"), (a = "bottom"), (n = "originY")),
                  (r[-1] = o),
                  (r[1] = a),
                  e.target.flipX && (c *= -1),
                  e.target.flipY && (c *= -1),
                  0 === s
                    ? ((e.skewSign = -h * t * c), (e[n] = r[-t]))
                    : ((s = s > 0 ? 1 : -1), (e.skewSign = s), (e[n] = r[s * h * c]));
              },
              _skewObject: function (t, e, i) {
                var r = this._currentTransform,
                  s = r.target,
                  o = !1,
                  a = s.get("lockSkewingX"),
                  h = s.get("lockSkewingY");
                if ((a && "x" === i) || (h && "y" === i)) return !1;
                var c,
                  l,
                  u = s.getCenterPoint(),
                  f = s.toLocalPoint(new n.Point(t, e), "center", "center")[i],
                  d = s.toLocalPoint(new n.Point(r.lastX, r.lastY), "center", "center")[i],
                  g = s._getTransformedDimensions();
                return (
                  this._changeSkewTransformOrigin(f - d, r, i),
                  (c = s.toLocalPoint(new n.Point(t, e), r.originX, r.originY)[i]),
                  (l = s.translateToOriginPoint(u, r.originX, r.originY)),
                  (o = this._setObjectSkew(c, r, i, g)),
                  (r.lastX = t),
                  (r.lastY = e),
                  s.setPositionByOrigin(l, r.originX, r.originY),
                  o
                );
              },
              _setObjectSkew: function (t, e, i, r) {
                var s,
                  o,
                  a,
                  h,
                  c,
                  l,
                  u,
                  f,
                  d,
                  g = e.target,
                  p = !1,
                  m = e.skewSign;
                return (
                  "x" === i
                    ? ((h = "y"), (c = "Y"), (l = "X"), (f = 0), (d = g.skewY))
                    : ((h = "x"), (c = "X"), (l = "Y"), (f = g.skewX), (d = 0)),
                  (a = g._getTransformedDimensions(f, d)),
                  (u = 2 * Math.abs(t) - a[i]),
                  u <= 2
                    ? (s = 0)
                    : ((s = m * Math.atan(u / g["scale" + l] / (a[h] / g["scale" + c]))),
                      (s = n.util.radiansToDegrees(s))),
                  (p = g["skew" + l] !== s),
                  g.set("skew" + l, s),
                  0 !== g["skew" + c] &&
                    ((o = g._getTransformedDimensions()),
                    (s = (r[h] / o[h]) * g["scale" + c]),
                    g.set("scale" + c, s)),
                  p
                );
              },
              _scaleObject: function (t, e, i) {
                var r = this._currentTransform,
                  s = r.target,
                  o = s.lockScalingX,
                  a = s.lockScalingY,
                  h = s.lockScalingFlip;
                if (o && a) return !1;
                var c = s.translateToOriginPoint(s.getCenterPoint(), r.originX, r.originY),
                  l = s.toLocalPoint(new n.Point(t, e), r.originX, r.originY),
                  u = s._getTransformedDimensions(),
                  f = !1;
                return (
                  this._setLocalMouse(l, r),
                  (f = this._setObjectScale(l, r, o, a, i, h, u)),
                  s.setPositionByOrigin(c, r.originX, r.originY),
                  f
                );
              },
              _setObjectScale: function (t, e, i, n, r, s, o) {
                var a = e.target,
                  h = !1,
                  c = !1,
                  l = !1,
                  u = (t.x * a.scaleX) / o.x,
                  f = (t.y * a.scaleY) / o.y,
                  d = a.scaleX !== u,
                  g = a.scaleY !== f;
                return (
                  s && u <= 0 && u < a.scaleX && ((h = !0), (t.x = 0)),
                  s && f <= 0 && f < a.scaleY && ((c = !0), (t.y = 0)),
                  "equally" !== r || i || n
                    ? r
                      ? "x" !== r || a.get("lockUniScaling")
                        ? "y" !== r ||
                          a.get("lockUniScaling") ||
                          c ||
                          n ||
                          (a.set("scaleY", f) && (l = g))
                        : h || i || (a.set("scaleX", u) && (l = d))
                      : (h || i || (a.set("scaleX", u) && (l = l || d)),
                        c || n || (a.set("scaleY", f) && (l = l || g)))
                    : (l = this._scaleObjectEqually(t, a, e, o)),
                  (e.newScaleX = u),
                  (e.newScaleY = f),
                  h || c || this._flipObject(e, r),
                  l
                );
              },
              _scaleObjectEqually: function (t, e, i, n) {
                var r,
                  s,
                  o,
                  a = t.y + t.x,
                  h = (n.y * i.original.scaleY) / e.scaleY + (n.x * i.original.scaleX) / e.scaleX,
                  c = t.x < 0 ? -1 : 1,
                  l = t.y < 0 ? -1 : 1;
                return (
                  (s = c * Math.abs((i.original.scaleX * a) / h)),
                  (o = l * Math.abs((i.original.scaleY * a) / h)),
                  (r = s !== e.scaleX || o !== e.scaleY),
                  e.set("scaleX", s),
                  e.set("scaleY", o),
                  r
                );
              },
              _flipObject: function (t, e) {
                t.newScaleX < 0 &&
                  "y" !== e &&
                  ("left" === t.originX
                    ? (t.originX = "right")
                    : "right" === t.originX && (t.originX = "left")),
                  t.newScaleY < 0 &&
                    "x" !== e &&
                    ("top" === t.originY
                      ? (t.originY = "bottom")
                      : "bottom" === t.originY && (t.originY = "top"));
              },
              _setLocalMouse: function (t, e) {
                var i = e.target,
                  n = this.getZoom(),
                  r = i.padding / n;
                "right" === e.originX
                  ? (t.x *= -1)
                  : "center" === e.originX &&
                    ((t.x *= 2 * e.mouseXSign), t.x < 0 && (e.mouseXSign = -e.mouseXSign)),
                  "bottom" === e.originY
                    ? (t.y *= -1)
                    : "center" === e.originY &&
                      ((t.y *= 2 * e.mouseYSign), t.y < 0 && (e.mouseYSign = -e.mouseYSign)),
                  s(t.x) > r ? (t.x < 0 ? (t.x += r) : (t.x -= r)) : (t.x = 0),
                  s(t.y) > r ? (t.y < 0 ? (t.y += r) : (t.y -= r)) : (t.y = 0);
              },
              _rotateObject: function (t, e) {
                var n = this._currentTransform,
                  s = n.target,
                  o = s.translateToOriginPoint(s.getCenterPoint(), n.originX, n.originY);
                if (s.lockRotation) return !1;
                var a = r(n.ey - o.y, n.ex - o.x),
                  h = r(e - o.y, t - o.x),
                  c = i(h - a + n.theta),
                  l = !0;
                if (s.snapAngle > 0) {
                  var u = s.snapAngle,
                    f = s.snapThreshold || u,
                    d = Math.ceil(c / u) * u,
                    g = Math.floor(c / u) * u;
                  Math.abs(c - g) < f ? (c = g) : Math.abs(c - d) < f && (c = d);
                }
                return (
                  c < 0 && (c = 360 + c),
                  (c %= 360),
                  s.angle === c
                    ? (l = !1)
                    : ((s.angle = c), s.setPositionByOrigin(o, n.originX, n.originY)),
                  l
                );
              },
              setCursor: function (t) {
                this.upperCanvasEl.style.cursor = t;
              },
              _drawSelection: function (t) {
                var e = this._groupSelector,
                  i = e.left,
                  r = e.top,
                  h = s(i),
                  c = s(r);
                if (
                  (this.selectionColor &&
                    ((t.fillStyle = this.selectionColor),
                    t.fillRect(e.ex - (i > 0 ? 0 : -i), e.ey - (r > 0 ? 0 : -r), h, c)),
                  this.selectionLineWidth && this.selectionBorderColor)
                )
                  if (
                    ((t.lineWidth = this.selectionLineWidth),
                    (t.strokeStyle = this.selectionBorderColor),
                    this.selectionDashArray.length > 1 && !o)
                  ) {
                    var l = e.ex + a - (i > 0 ? 0 : h),
                      u = e.ey + a - (r > 0 ? 0 : c);
                    t.beginPath(),
                      n.util.drawDashedLine(t, l, u, l + h, u, this.selectionDashArray),
                      n.util.drawDashedLine(
                        t,
                        l,
                        u + c - 1,
                        l + h,
                        u + c - 1,
                        this.selectionDashArray
                      ),
                      n.util.drawDashedLine(t, l, u, l, u + c, this.selectionDashArray),
                      n.util.drawDashedLine(
                        t,
                        l + h - 1,
                        u,
                        l + h - 1,
                        u + c,
                        this.selectionDashArray
                      ),
                      t.closePath(),
                      t.stroke();
                  } else
                    n.Object.prototype._setLineDash.call(this, t, this.selectionDashArray),
                      t.strokeRect(e.ex + a - (i > 0 ? 0 : h), e.ey + a - (r > 0 ? 0 : c), h, c);
              },
              findTarget: function (t, e) {
                if (!this.skipTargetFind) {
                  var i,
                    n,
                    r = !0,
                    s = this.getPointer(t, r),
                    o = this._activeObject,
                    a = this.getActiveObjects();
                  if (
                    ((this.targets = []),
                    a.length > 1 && !e && o === this._searchPossibleTargets([o], s))
                  )
                    return o;
                  if (1 === a.length && o._findTargetCorner(s)) return o;
                  if (1 === a.length && o === this._searchPossibleTargets([o], s)) {
                    if (!this.preserveObjectStacking) return o;
                    (i = o), (n = this.targets), (this.targets = []);
                  }
                  var h = this._searchPossibleTargets(this._objects, s);
                  return (
                    t[this.altSelectionKey] && h && i && h !== i && ((h = i), (this.targets = n)), h
                  );
                }
              },
              _checkTarget: function (t, e, i) {
                if (e && e.visible && e.evented && this.containsPoint(null, e, t)) {
                  if ((!this.perPixelTargetFind && !e.perPixelTargetFind) || e.isEditing) return !0;
                  var n = this.isTargetTransparent(e, i.x, i.y);
                  if (!n) return !0;
                }
              },
              _searchPossibleTargets: function (t, e) {
                var i,
                  r,
                  s = t.length;
                while (s--) {
                  var o = t[s],
                    a =
                      o.group && "activeSelection" !== o.group.type
                        ? this._normalizePointer(o.group, e)
                        : e;
                  if (this._checkTarget(a, o, e)) {
                    (i = t[s]),
                      i.subTargetCheck &&
                        i instanceof n.Group &&
                        ((r = this._searchPossibleTargets(i._objects, e)),
                        r && this.targets.push(r));
                    break;
                  }
                }
                return i;
              },
              restorePointerVpt: function (t) {
                return n.util.transformPoint(t, n.util.invertTransform(this.viewportTransform));
              },
              getPointer: function (e, i) {
                if (this._absolutePointer && !i) return this._absolutePointer;
                if (this._pointer && i) return this._pointer;
                var n,
                  r = t(e),
                  s = this.upperCanvasEl,
                  o = s.getBoundingClientRect(),
                  a = o.width || 0,
                  h = o.height || 0;
                return (
                  (a && h) ||
                    ("top" in o && "bottom" in o && (h = Math.abs(o.top - o.bottom)),
                    "right" in o && "left" in o && (a = Math.abs(o.right - o.left))),
                  this.calcOffset(),
                  (r.x = r.x - this._offset.left),
                  (r.y = r.y - this._offset.top),
                  i || (r = this.restorePointerVpt(r)),
                  (n =
                    0 === a || 0 === h
                      ? { width: 1, height: 1 }
                      : { width: s.width / a, height: s.height / h }),
                  { x: r.x * n.width, y: r.y * n.height }
                );
              },
              _createUpperCanvas: function () {
                var t = this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/, "");
                this.upperCanvasEl
                  ? (this.upperCanvasEl.className = "")
                  : (this.upperCanvasEl = this._createCanvasElement()),
                  n.util.addClass(this.upperCanvasEl, "upper-canvas " + t),
                  this.wrapperEl.appendChild(this.upperCanvasEl),
                  this._copyCanvasStyle(this.lowerCanvasEl, this.upperCanvasEl),
                  this._applyCanvasStyle(this.upperCanvasEl),
                  (this.contextTop = this.upperCanvasEl.getContext("2d"));
              },
              _createCacheCanvas: function () {
                (this.cacheCanvasEl = this._createCanvasElement()),
                  this.cacheCanvasEl.setAttribute("width", this.width),
                  this.cacheCanvasEl.setAttribute("height", this.height),
                  (this.contextCache = this.cacheCanvasEl.getContext("2d"));
              },
              _initWrapperElement: function () {
                (this.wrapperEl = n.util.wrapElement(this.lowerCanvasEl, "div", {
                  class: this.containerClass,
                })),
                  n.util.setStyle(this.wrapperEl, {
                    width: this.width + "px",
                    height: this.height + "px",
                    position: "relative",
                  }),
                  n.util.makeElementUnselectable(this.wrapperEl);
              },
              _applyCanvasStyle: function (t) {
                var e = this.width || t.width,
                  i = this.height || t.height;
                n.util.setStyle(t, {
                  position: "absolute",
                  width: e + "px",
                  height: i + "px",
                  left: 0,
                  top: 0,
                  "touch-action": this.allowTouchScrolling ? "manipulation" : "none",
                }),
                  (t.width = e),
                  (t.height = i),
                  n.util.makeElementUnselectable(t);
              },
              _copyCanvasStyle: function (t, e) {
                e.style.cssText = t.style.cssText;
              },
              getSelectionContext: function () {
                return this.contextTop;
              },
              getSelectionElement: function () {
                return this.upperCanvasEl;
              },
              getActiveObject: function () {
                return this._activeObject;
              },
              getActiveObjects: function () {
                var t = this._activeObject;
                return t
                  ? "activeSelection" === t.type && t._objects
                    ? t._objects.slice(0)
                    : [t]
                  : [];
              },
              _onObjectRemoved: function (t) {
                t === this._activeObject &&
                  (this.fire("before:selection:cleared", { target: t }),
                  this._discardActiveObject(),
                  this.fire("selection:cleared", { target: t }),
                  t.fire("deselected")),
                  this._hoveredTarget === t && (this._hoveredTarget = null),
                  this.callSuper("_onObjectRemoved", t);
              },
              _fireSelectionEvents: function (t, e) {
                var i = !1,
                  n = this.getActiveObjects(),
                  r = [],
                  s = [],
                  o = { e: e };
                t.forEach(function (t) {
                  -1 === n.indexOf(t) && ((i = !0), t.fire("deselected", o), s.push(t));
                }),
                  n.forEach(function (e) {
                    -1 === t.indexOf(e) && ((i = !0), e.fire("selected", o), r.push(e));
                  }),
                  t.length > 0 && n.length > 0
                    ? ((o.selected = r),
                      (o.deselected = s),
                      (o.updated = r[0] || s[0]),
                      (o.target = this._activeObject),
                      i && this.fire("selection:updated", o))
                    : n.length > 0
                    ? (1 === n.length && ((o.target = r[0]), this.fire("object:selected", o)),
                      (o.selected = r),
                      (o.target = this._activeObject),
                      this.fire("selection:created", o))
                    : t.length > 0 && ((o.deselected = s), this.fire("selection:cleared", o));
              },
              setActiveObject: function (t, e) {
                var i = this.getActiveObjects();
                return this._setActiveObject(t, e), this._fireSelectionEvents(i, e), this;
              },
              _setActiveObject: function (t, e) {
                return (
                  this._activeObject !== t &&
                  !!this._discardActiveObject(e, t) &&
                  !t.onSelect({ e: e }) &&
                  ((this._activeObject = t), !0)
                );
              },
              _discardActiveObject: function (t, e) {
                var i = this._activeObject;
                if (i) {
                  if (i.onDeselect({ e: t, object: e })) return !1;
                  this._activeObject = null;
                }
                return !0;
              },
              discardActiveObject: function (t) {
                var e = this.getActiveObjects();
                return (
                  e.length && this.fire("before:selection:cleared", { target: e[0], e: t }),
                  this._discardActiveObject(t),
                  this._fireSelectionEvents(e, t),
                  this
                );
              },
              dispose: function () {
                var t = this.wrapperEl;
                return (
                  this.removeListeners(),
                  t.removeChild(this.upperCanvasEl),
                  t.removeChild(this.lowerCanvasEl),
                  (this.contextCache = null),
                  (this.contextTop = null),
                  ["upperCanvasEl", "cacheCanvasEl"].forEach(
                    function (t) {
                      n.util.cleanUpJsdomNode(this[t]), (this[t] = void 0);
                    }.bind(this)
                  ),
                  t.parentNode && t.parentNode.replaceChild(this.lowerCanvasEl, this.wrapperEl),
                  delete this.wrapperEl,
                  n.StaticCanvas.prototype.dispose.call(this),
                  this
                );
              },
              clear: function () {
                return (
                  this.discardActiveObject(),
                  this.clearContext(this.contextTop),
                  this.callSuper("clear")
                );
              },
              drawControls: function (t) {
                var e = this._activeObject;
                e && e._renderControls(t);
              },
              _toObject: function (t, e, i) {
                var n = this._realizeGroupTransformOnObject(t),
                  r = this.callSuper("_toObject", t, e, i);
                return this._unwindGroupTransformOnObject(t, n), r;
              },
              _realizeGroupTransformOnObject: function (t) {
                if (
                  t.group &&
                  "activeSelection" === t.group.type &&
                  this._activeObject === t.group
                ) {
                  var e = [
                      "angle",
                      "flipX",
                      "flipY",
                      "left",
                      "scaleX",
                      "scaleY",
                      "skewX",
                      "skewY",
                      "top",
                    ],
                    i = {};
                  return (
                    e.forEach(function (e) {
                      i[e] = t[e];
                    }),
                    this._activeObject.realizeTransform(t),
                    i
                  );
                }
                return null;
              },
              _unwindGroupTransformOnObject: function (t, e) {
                e && t.set(e);
              },
              _setSVGObject: function (t, e, i) {
                var n = this._realizeGroupTransformOnObject(e);
                this.callSuper("_setSVGObject", t, e, i), this._unwindGroupTransformOnObject(e, n);
              },
              setViewportTransform: function (t) {
                this.renderOnAddRemove &&
                  this._activeObject &&
                  this._activeObject.isEditing &&
                  this._activeObject.clearContextTop(),
                  n.StaticCanvas.prototype.setViewportTransform.call(this, t);
              },
            })),
            n.StaticCanvas))
              "prototype" !== h && (n.Canvas[h] = n.StaticCanvas[h]);
            n.isTouchSupported && (n.Canvas.prototype._setCursorFromEvent = function () {});
          })(),
          (function () {
            var t = { mt: 0, tr: 1, mr: 2, br: 3, mb: 4, bl: 5, ml: 6, tl: 7 },
              e = n.util.addListener,
              i = n.util.removeListener,
              r = 3,
              s = 2,
              o = 1,
              a = { passive: !1 };
            function h(t, e) {
              return "which" in t ? t.which === e : t.button === e - 1;
            }
            n.util.object.extend(n.Canvas.prototype, {
              cursorMap: [
                "n-resize",
                "ne-resize",
                "e-resize",
                "se-resize",
                "s-resize",
                "sw-resize",
                "w-resize",
                "nw-resize",
              ],
              _initEventListeners: function () {
                this.removeListeners(), this._bindEvents(), this.addOrRemove(e, "add");
              },
              addOrRemove: function (t, e) {
                t(n.window, "resize", this._onResize),
                  t(this.upperCanvasEl, "mousedown", this._onMouseDown),
                  t(this.upperCanvasEl, "mousemove", this._onMouseMove, a),
                  t(this.upperCanvasEl, "mouseout", this._onMouseOut),
                  t(this.upperCanvasEl, "mouseenter", this._onMouseEnter),
                  t(this.upperCanvasEl, "wheel", this._onMouseWheel),
                  t(this.upperCanvasEl, "contextmenu", this._onContextMenu),
                  t(this.upperCanvasEl, "dblclick", this._onDoubleClick),
                  t(this.upperCanvasEl, "touchstart", this._onMouseDown, a),
                  t(this.upperCanvasEl, "touchmove", this._onMouseMove, a),
                  t(this.upperCanvasEl, "dragover", this._onDragOver),
                  t(this.upperCanvasEl, "dragenter", this._onDragEnter),
                  t(this.upperCanvasEl, "dragleave", this._onDragLeave),
                  t(this.upperCanvasEl, "drop", this._onDrop),
                  "undefined" !== typeof eventjs &&
                    e in eventjs &&
                    (eventjs[e](this.upperCanvasEl, "gesture", this._onGesture),
                    eventjs[e](this.upperCanvasEl, "drag", this._onDrag),
                    eventjs[e](this.upperCanvasEl, "orientation", this._onOrientationChange),
                    eventjs[e](this.upperCanvasEl, "shake", this._onShake),
                    eventjs[e](this.upperCanvasEl, "longpress", this._onLongPress));
              },
              removeListeners: function () {
                this.addOrRemove(i, "remove"),
                  i(n.document, "mouseup", this._onMouseUp),
                  i(n.document, "touchend", this._onMouseUp, a),
                  i(n.document, "mousemove", this._onMouseMove, a),
                  i(n.document, "touchmove", this._onMouseMove, a);
              },
              _bindEvents: function () {
                this.eventsBound ||
                  ((this._onMouseDown = this._onMouseDown.bind(this)),
                  (this._onMouseMove = this._onMouseMove.bind(this)),
                  (this._onMouseUp = this._onMouseUp.bind(this)),
                  (this._onResize = this._onResize.bind(this)),
                  (this._onGesture = this._onGesture.bind(this)),
                  (this._onDrag = this._onDrag.bind(this)),
                  (this._onShake = this._onShake.bind(this)),
                  (this._onLongPress = this._onLongPress.bind(this)),
                  (this._onOrientationChange = this._onOrientationChange.bind(this)),
                  (this._onMouseWheel = this._onMouseWheel.bind(this)),
                  (this._onMouseOut = this._onMouseOut.bind(this)),
                  (this._onMouseEnter = this._onMouseEnter.bind(this)),
                  (this._onContextMenu = this._onContextMenu.bind(this)),
                  (this._onDoubleClick = this._onDoubleClick.bind(this)),
                  (this._onDragOver = this._onDragOver.bind(this)),
                  (this._onDragEnter = this._simpleEventHandler.bind(this, "dragenter")),
                  (this._onDragLeave = this._simpleEventHandler.bind(this, "dragleave")),
                  (this._onDrop = this._simpleEventHandler.bind(this, "drop")),
                  (this.eventsBound = !0));
              },
              _onGesture: function (t, e) {
                this.__onTransformGesture && this.__onTransformGesture(t, e);
              },
              _onDrag: function (t, e) {
                this.__onDrag && this.__onDrag(t, e);
              },
              _onMouseWheel: function (t) {
                this.__onMouseWheel(t);
              },
              _onMouseOut: function (t) {
                var e = this._hoveredTarget;
                this.fire("mouse:out", { target: e, e: t }),
                  (this._hoveredTarget = null),
                  e && e.fire("mouseout", { e: t }),
                  this._iTextInstances &&
                    this._iTextInstances.forEach(function (t) {
                      t.isEditing && t.hiddenTextarea.focus();
                    });
              },
              _onMouseEnter: function (t) {
                this.findTarget(t) ||
                  (this.fire("mouse:over", { target: null, e: t }), (this._hoveredTarget = null));
              },
              _onOrientationChange: function (t, e) {
                this.__onOrientationChange && this.__onOrientationChange(t, e);
              },
              _onShake: function (t, e) {
                this.__onShake && this.__onShake(t, e);
              },
              _onLongPress: function (t, e) {
                this.__onLongPress && this.__onLongPress(t, e);
              },
              _onDragOver: function (t) {
                t.preventDefault();
                var e = this._simpleEventHandler("dragover", t);
                this._fireEnterLeaveEvents(e, t);
              },
              _onContextMenu: function (t) {
                return this.stopContextMenu && (t.stopPropagation(), t.preventDefault()), !1;
              },
              _onDoubleClick: function (t) {
                this._cacheTransformEventData(t),
                  this._handleEvent(t, "dblclick"),
                  this._resetTransformEventData(t);
              },
              _onMouseDown: function (t) {
                this.__onMouseDown(t),
                  this._resetTransformEventData(),
                  e(n.document, "touchend", this._onMouseUp, a),
                  e(n.document, "touchmove", this._onMouseMove, a),
                  i(this.upperCanvasEl, "mousemove", this._onMouseMove, a),
                  i(this.upperCanvasEl, "touchmove", this._onMouseMove, a),
                  "touchstart" === t.type
                    ? i(this.upperCanvasEl, "mousedown", this._onMouseDown)
                    : (e(n.document, "mouseup", this._onMouseUp),
                      e(n.document, "mousemove", this._onMouseMove, a));
              },
              _onMouseUp: function (t) {
                if (
                  (this.__onMouseUp(t),
                  this._resetTransformEventData(),
                  i(n.document, "mouseup", this._onMouseUp),
                  i(n.document, "touchend", this._onMouseUp, a),
                  i(n.document, "mousemove", this._onMouseMove, a),
                  i(n.document, "touchmove", this._onMouseMove, a),
                  e(this.upperCanvasEl, "mousemove", this._onMouseMove, a),
                  e(this.upperCanvasEl, "touchmove", this._onMouseMove, a),
                  "touchend" === t.type)
                ) {
                  var r = this;
                  setTimeout(function () {
                    e(r.upperCanvasEl, "mousedown", r._onMouseDown);
                  }, 400);
                }
              },
              _onMouseMove: function (t) {
                !this.allowTouchScrolling && t.preventDefault && t.preventDefault(),
                  this.__onMouseMove(t);
              },
              _onResize: function () {
                this.calcOffset();
              },
              _shouldRender: function (t) {
                var e = this._activeObject;
                return !!(!!e !== !!t || (e && t && e !== t)) || (e && e.isEditing, !1);
              },
              __onMouseUp: function (t) {
                var e,
                  i = this._currentTransform,
                  n = this._groupSelector,
                  a = !1,
                  c = !n || (0 === n.left && 0 === n.top);
                if (
                  (this._cacheTransformEventData(t),
                  (e = this._target),
                  this._handleEvent(t, "up:before"),
                  !h(t, r))
                )
                  return h(t, s)
                    ? (this.fireMiddleClick && this._handleEvent(t, "up", s, c),
                      void this._resetTransformEventData())
                    : void (this.isDrawingMode && this._isCurrentlyDrawing
                        ? this._onMouseUpInDrawingMode(t)
                        : (i && (this._finalizeCurrentTransform(t), (a = i.actionPerformed)),
                          c || (this._maybeGroupObjects(t), a || (a = this._shouldRender(e))),
                          e && (e.isMoving = !1),
                          this._setCursorFromEvent(t, e),
                          this._handleEvent(t, "up", o, c),
                          (this._groupSelector = null),
                          (this._currentTransform = null),
                          e && (e.__corner = 0),
                          a ? this.requestRenderAll() : c || this.renderTop()));
                this.fireRightClick && this._handleEvent(t, "up", r, c);
              },
              _simpleEventHandler: function (t, e) {
                var i = this.findTarget(e),
                  n = this.targets,
                  r = { e: e, target: i, subTargets: n };
                if ((this.fire(t, r), i && i.fire(t, r), !n)) return i;
                for (var s = 0; s < n.length; s++) n[s].fire(t, r);
                return i;
              },
              _handleEvent: function (t, e, i, n) {
                var r = this._target,
                  s = this.targets || [],
                  a = {
                    e: t,
                    target: r,
                    subTargets: s,
                    button: i || o,
                    isClick: n || !1,
                    pointer: this._pointer,
                    absolutePointer: this._absolutePointer,
                    transform: this._currentTransform,
                  };
                this.fire("mouse:" + e, a), r && r.fire("mouse" + e, a);
                for (var h = 0; h < s.length; h++) s[h].fire("mouse" + e, a);
              },
              _finalizeCurrentTransform: function (t) {
                var e,
                  i = this._currentTransform,
                  n = i.target,
                  r = { e: t, target: n, transform: i };
                n._scaling && (n._scaling = !1),
                  n.setCoords(),
                  (i.actionPerformed || (this.stateful && n.hasStateChanged())) &&
                    (i.actionPerformed && ((e = this._addEventOptions(r, i)), this._fire(e, r)),
                    this._fire("modified", r));
              },
              _addEventOptions: function (t, e) {
                var i, n;
                switch (e.action) {
                  case "scaleX":
                    (i = "scaled"), (n = "x");
                    break;
                  case "scaleY":
                    (i = "scaled"), (n = "y");
                    break;
                  case "skewX":
                    (i = "skewed"), (n = "x");
                    break;
                  case "skewY":
                    (i = "skewed"), (n = "y");
                    break;
                  case "scale":
                    (i = "scaled"), (n = "equally");
                    break;
                  case "rotate":
                    i = "rotated";
                    break;
                  case "drag":
                    i = "moved";
                    break;
                }
                return (t.by = n), i;
              },
              _onMouseDownInDrawingMode: function (t) {
                (this._isCurrentlyDrawing = !0),
                  this.getActiveObject() && this.discardActiveObject(t).requestRenderAll(),
                  this.clipTo && n.util.clipContext(this, this.contextTop);
                var e = this.getPointer(t);
                this.freeDrawingBrush.onMouseDown(e), this._handleEvent(t, "down");
              },
              _onMouseMoveInDrawingMode: function (t) {
                if (this._isCurrentlyDrawing) {
                  var e = this.getPointer(t);
                  this.freeDrawingBrush.onMouseMove(e);
                }
                this.setCursor(this.freeDrawingCursor), this._handleEvent(t, "move");
              },
              _onMouseUpInDrawingMode: function (t) {
                (this._isCurrentlyDrawing = !1),
                  this.clipTo && this.contextTop.restore(),
                  this.freeDrawingBrush.onMouseUp(),
                  this._handleEvent(t, "up");
              },
              __onMouseDown: function (t) {
                this._cacheTransformEventData(t), this._handleEvent(t, "down:before");
                var e = this._target;
                if (h(t, r)) this.fireRightClick && this._handleEvent(t, "down", r);
                else if (h(t, s)) this.fireMiddleClick && this._handleEvent(t, "down", s);
                else if (this.isDrawingMode) this._onMouseDownInDrawingMode(t);
                else if (!this._currentTransform) {
                  var i = this._pointer;
                  this._previousPointer = i;
                  var n = this._shouldRender(e),
                    o = this._shouldGroup(t, e);
                  if (
                    (this._shouldClearSelection(t, e)
                      ? this.discardActiveObject(t)
                      : o && (this._handleGrouping(t, e), (e = this._activeObject)),
                    !this.selection ||
                      (e && (e.selectable || e.isEditing || e === this._activeObject)) ||
                      (this._groupSelector = { ex: i.x, ey: i.y, top: 0, left: 0 }),
                    e)
                  ) {
                    var a = e === this._activeObject;
                    e.selectable && this.setActiveObject(e, t),
                      e !== this._activeObject ||
                        (!e.__corner && o) ||
                        this._setupCurrentTransform(t, e, a);
                  }
                  this._handleEvent(t, "down"), (n || o) && this.requestRenderAll();
                }
              },
              _resetTransformEventData: function () {
                (this._target = null), (this._pointer = null), (this._absolutePointer = null);
              },
              _cacheTransformEventData: function (t) {
                this._resetTransformEventData(),
                  (this._pointer = this.getPointer(t, !0)),
                  (this._absolutePointer = this.restorePointerVpt(this._pointer)),
                  (this._target = this._currentTransform
                    ? this._currentTransform.target
                    : this.findTarget(t) || null);
              },
              _beforeTransform: function (t) {
                var e = this._currentTransform;
                this.stateful && e.target.saveState(),
                  this.fire("before:transform", { e: t, transform: e }),
                  e.corner && this.onBeforeScaleRotate(e.target);
              },
              __onMouseMove: function (t) {
                var e, i;
                if (
                  (this._handleEvent(t, "move:before"),
                  this._cacheTransformEventData(t),
                  this.isDrawingMode)
                )
                  this._onMouseMoveInDrawingMode(t);
                else if (!("undefined" !== typeof t.touches && t.touches.length > 1)) {
                  var n = this._groupSelector;
                  n
                    ? ((i = this._pointer),
                      (n.left = i.x - n.ex),
                      (n.top = i.y - n.ey),
                      this.renderTop())
                    : this._currentTransform
                    ? this._transformObject(t)
                    : ((e = this.findTarget(t) || null),
                      this._setCursorFromEvent(t, e),
                      this._fireOverOutEvents(e, t)),
                    this._handleEvent(t, "move"),
                    this._resetTransformEventData();
                }
              },
              _fireOverOutEvents: function (t, e) {
                this.fireSynteticInOutEvents(t, e, {
                  targetName: "_hoveredTarget",
                  canvasEvtOut: "mouse:out",
                  evtOut: "mouseout",
                  canvasEvtIn: "mouse:over",
                  evtIn: "mouseover",
                });
              },
              _fireEnterLeaveEvents: function (t, e) {
                this.fireSynteticInOutEvents(t, e, {
                  targetName: "_draggedoverTarget",
                  evtOut: "dragleave",
                  evtIn: "dragenter",
                });
              },
              fireSynteticInOutEvents: function (t, e, i) {
                var n,
                  r,
                  s,
                  o,
                  a = this[i.targetName],
                  h = a !== t,
                  c = i.canvasEvtIn,
                  l = i.canvasEvtOut;
                h &&
                  ((n = { e: e, target: t, previousTarget: a }),
                  (r = { e: e, target: a, nextTarget: t }),
                  (this[i.targetName] = t)),
                  (o = t && h),
                  (s = a && h),
                  s && (l && this.fire(l, r), a.fire(i.evtOut, r)),
                  o && (c && this.fire(c, n), t.fire(i.evtIn, n));
              },
              __onMouseWheel: function (t) {
                this._cacheTransformEventData(t),
                  this._handleEvent(t, "wheel"),
                  this._resetTransformEventData();
              },
              _transformObject: function (t) {
                var e = this.getPointer(t),
                  i = this._currentTransform;
                (i.reset = !1),
                  (i.target.isMoving = !0),
                  (i.shiftKey = t.shiftKey),
                  (i.altKey = t[this.centeredKey]),
                  this._beforeScaleTransform(t, i),
                  this._performTransformAction(t, i, e),
                  i.actionPerformed && this.requestRenderAll();
              },
              _performTransformAction: function (t, e, i) {
                var n = i.x,
                  r = i.y,
                  s = e.action,
                  o = !1,
                  a = { target: e.target, e: t, transform: e, pointer: i };
                "rotate" === s
                  ? (o = this._rotateObject(n, r)) && this._fire("rotating", a)
                  : "scale" === s
                  ? (o = this._onScale(t, e, n, r)) && this._fire("scaling", a)
                  : "scaleX" === s
                  ? (o = this._scaleObject(n, r, "x")) && this._fire("scaling", a)
                  : "scaleY" === s
                  ? (o = this._scaleObject(n, r, "y")) && this._fire("scaling", a)
                  : "skewX" === s
                  ? (o = this._skewObject(n, r, "x")) && this._fire("skewing", a)
                  : "skewY" === s
                  ? (o = this._skewObject(n, r, "y")) && this._fire("skewing", a)
                  : ((o = this._translateObject(n, r)),
                    o &&
                      (this._fire("moving", a),
                      this.setCursor(a.target.moveCursor || this.moveCursor))),
                  (e.actionPerformed = e.actionPerformed || o);
              },
              _fire: function (t, e) {
                this.fire("object:" + t, e), e.target.fire(t, e);
              },
              _beforeScaleTransform: function (t, e) {
                if ("scale" === e.action || "scaleX" === e.action || "scaleY" === e.action) {
                  var i = this._shouldCenterTransform(e.target);
                  ((i && ("center" !== e.originX || "center" !== e.originY)) ||
                    (!i && "center" === e.originX && "center" === e.originY)) &&
                    (this._resetCurrentTransform(), (e.reset = !0));
                }
              },
              _onScale: function (t, e, i, n) {
                return this._isUniscalePossible(t, e.target)
                  ? ((e.currentAction = "scale"), this._scaleObject(i, n))
                  : (e.reset || "scale" !== e.currentAction || this._resetCurrentTransform(),
                    (e.currentAction = "scaleEqually"),
                    this._scaleObject(i, n, "equally"));
              },
              _isUniscalePossible: function (t, e) {
                return (t[this.uniScaleKey] || this.uniScaleTransform) && !e.get("lockUniScaling");
              },
              _setCursorFromEvent: function (t, e) {
                if (!e) return this.setCursor(this.defaultCursor), !1;
                var i = e.hoverCursor || this.hoverCursor,
                  n =
                    this._activeObject && "activeSelection" === this._activeObject.type
                      ? this._activeObject
                      : null,
                  r = (!n || !n.contains(e)) && e._findTargetCorner(this.getPointer(t, !0));
                r ? this.setCursor(this.getCornerCursor(r, e, t)) : this.setCursor(i);
              },
              getCornerCursor: function (e, i, n) {
                return this.actionIsDisabled(e, i, n)
                  ? this.notAllowedCursor
                  : e in t
                  ? this._getRotatedCornerCursor(e, i, n)
                  : "mtr" === e && i.hasRotatingPoint
                  ? this.rotationCursor
                  : this.defaultCursor;
              },
              actionIsDisabled: function (t, e, i) {
                return "mt" === t || "mb" === t
                  ? i[this.altActionKey]
                    ? e.lockSkewingX
                    : e.lockScalingY
                  : "ml" === t || "mr" === t
                  ? i[this.altActionKey]
                    ? e.lockSkewingY
                    : e.lockScalingX
                  : "mtr" === t
                  ? e.lockRotation
                  : this._isUniscalePossible(i, e)
                  ? e.lockScalingX && e.lockScalingY
                  : e.lockScalingX || e.lockScalingY;
              },
              _getRotatedCornerCursor: function (e, i, n) {
                var r = Math.round((i.angle % 360) / 45);
                return (
                  r < 0 && (r += 8),
                  (r += t[e]),
                  n[this.altActionKey] && t[e] % 2 === 0 && (r += 2),
                  (r %= 8),
                  this.cursorMap[r]
                );
              },
            });
          })(),
          (function () {
            var t = Math.min,
              e = Math.max;
            n.util.object.extend(n.Canvas.prototype, {
              _shouldGroup: function (t, e) {
                var i = this._activeObject;
                return (
                  i &&
                  this._isSelectionKeyPressed(t) &&
                  e &&
                  e.selectable &&
                  this.selection &&
                  (i !== e || "activeSelection" === i.type) &&
                  !e.onSelect({ e: t })
                );
              },
              _handleGrouping: function (t, e) {
                var i = this._activeObject;
                i.__corner ||
                  ((e !== i || ((e = this.findTarget(t, !0)), e && e.selectable)) &&
                    (i && "activeSelection" === i.type
                      ? this._updateActiveSelection(e, t)
                      : this._createActiveSelection(e, t)));
              },
              _updateActiveSelection: function (t, e) {
                var i = this._activeObject,
                  n = i._objects.slice(0);
                i.contains(t)
                  ? (i.removeWithUpdate(t),
                    (this._hoveredTarget = t),
                    1 === i.size() && this._setActiveObject(i.item(0), e))
                  : (i.addWithUpdate(t), (this._hoveredTarget = i)),
                  this._fireSelectionEvents(n, e);
              },
              _createActiveSelection: function (t, e) {
                var i = this.getActiveObjects(),
                  n = this._createGroup(t);
                (this._hoveredTarget = n),
                  this._setActiveObject(n, e),
                  this._fireSelectionEvents(i, e);
              },
              _createGroup: function (t) {
                var e = this._objects,
                  i = e.indexOf(this._activeObject) < e.indexOf(t),
                  r = i ? [this._activeObject, t] : [t, this._activeObject];
                return (
                  this._activeObject.isEditing && this._activeObject.exitEditing(),
                  new n.ActiveSelection(r, { canvas: this })
                );
              },
              _groupSelectedObjects: function (t) {
                var e,
                  i = this._collectObjects(t);
                1 === i.length
                  ? this.setActiveObject(i[0], t)
                  : i.length > 1 &&
                    ((e = new n.ActiveSelection(i.reverse(), { canvas: this })),
                    this.setActiveObject(e, t));
              },
              _collectObjects: function (i) {
                for (
                  var r,
                    s = [],
                    o = this._groupSelector.ex,
                    a = this._groupSelector.ey,
                    h = o + this._groupSelector.left,
                    c = a + this._groupSelector.top,
                    l = new n.Point(t(o, h), t(a, c)),
                    u = new n.Point(e(o, h), e(a, c)),
                    f = !this.selectionFullyContained,
                    d = o === h && a === c,
                    g = this._objects.length;
                  g--;

                )
                  if (
                    ((r = this._objects[g]),
                    r &&
                      r.selectable &&
                      r.visible &&
                      !r.onSelect({ e: i }) &&
                      ((f && r.intersectsWithRect(l, u)) ||
                        r.isContainedWithinRect(l, u) ||
                        (f && r.containsPoint(l)) ||
                        (f && r.containsPoint(u))) &&
                      (s.push(r), d))
                  )
                    break;
                return s;
              },
              _maybeGroupObjects: function (t) {
                this.selection && this._groupSelector && this._groupSelectedObjects(t),
                  this.setCursor(this.defaultCursor),
                  (this._groupSelector = null);
              },
            });
          })(),
          (function () {
            n.util.object.extend(n.StaticCanvas.prototype, {
              toDataURL: function (t) {
                t || (t = {});
                var e = t.format || "png",
                  i = t.quality || 1,
                  r = (t.multiplier || 1) * (t.enableRetinaScaling ? this.getRetinaScaling() : 1),
                  s = this.toCanvasElement(r, t);
                return n.util.toDataURL(s, e, i);
              },
              toCanvasElement: function (t, e) {
                (t = t || 1), (e = e || {});
                var i = (e.width || this.width) * t,
                  r = (e.height || this.height) * t,
                  s = this.getZoom(),
                  o = this.width,
                  a = this.height,
                  h = s * t,
                  c = this.viewportTransform,
                  l = (c[4] - (e.left || 0)) * t,
                  u = (c[5] - (e.top || 0)) * t,
                  f = this.interactive,
                  d = this.contextContainer,
                  g = [h, 0, 0, h, l, u],
                  p = n.util.createCanvasElement();
                return (
                  (p.width = i),
                  (p.height = r),
                  (this.interactive = !1),
                  (this.viewportTransform = g),
                  (this.width = i),
                  (this.height = r),
                  this.calcViewportBoundaries(),
                  (this.contextContainer = p.getContext("2d")),
                  this.renderAll(),
                  (this.viewportTransform = c),
                  (this.width = o),
                  (this.height = a),
                  this.calcViewportBoundaries(),
                  (this.contextContainer = d),
                  (this.interactive = f),
                  p
                );
              },
            });
          })(),
          n.util.object.extend(n.StaticCanvas.prototype, {
            loadFromDatalessJSON: function (t, e, i) {
              return this.loadFromJSON(t, e, i);
            },
            loadFromJSON: function (t, e, i) {
              if (t) {
                var r = "string" === typeof t ? JSON.parse(t) : n.util.object.clone(t),
                  s = this,
                  o = this.renderOnAddRemove;
                return (
                  (this.renderOnAddRemove = !1),
                  this._enlivenObjects(
                    r.objects,
                    function (t) {
                      s.clear(),
                        s._setBgOverlay(r, function () {
                          t.forEach(function (t, e) {
                            s.insertAt(t, e);
                          }),
                            (s.renderOnAddRemove = o),
                            delete r.objects,
                            delete r.backgroundImage,
                            delete r.overlayImage,
                            delete r.background,
                            delete r.overlay,
                            s._setOptions(r),
                            s.renderAll(),
                            e && e();
                        });
                    },
                    i
                  ),
                  this
                );
              }
            },
            _setBgOverlay: function (t, e) {
              var i = {
                backgroundColor: !1,
                overlayColor: !1,
                backgroundImage: !1,
                overlayImage: !1,
              };
              if (t.backgroundImage || t.overlayImage || t.background || t.overlay) {
                var n = function () {
                  i.backgroundImage &&
                    i.overlayImage &&
                    i.backgroundColor &&
                    i.overlayColor &&
                    e &&
                    e();
                };
                this.__setBgOverlay("backgroundImage", t.backgroundImage, i, n),
                  this.__setBgOverlay("overlayImage", t.overlayImage, i, n),
                  this.__setBgOverlay("backgroundColor", t.background, i, n),
                  this.__setBgOverlay("overlayColor", t.overlay, i, n);
              } else e && e();
            },
            __setBgOverlay: function (t, e, i, r) {
              var s = this;
              if (!e) return (i[t] = !0), void (r && r());
              "backgroundImage" === t || "overlayImage" === t
                ? n.util.enlivenObjects([e], function (e) {
                    (s[t] = e[0]), (i[t] = !0), r && r();
                  })
                : this["set" + n.util.string.capitalize(t, !0)](e, function () {
                    (i[t] = !0), r && r();
                  });
            },
            _enlivenObjects: function (t, e, i) {
              t && 0 !== t.length
                ? n.util.enlivenObjects(
                    t,
                    function (t) {
                      e && e(t);
                    },
                    null,
                    i
                  )
                : e && e([]);
            },
            _toDataURL: function (t, e) {
              this.clone(function (i) {
                e(i.toDataURL(t));
              });
            },
            _toDataURLWithMultiplier: function (t, e, i) {
              this.clone(function (n) {
                i(n.toDataURLWithMultiplier(t, e));
              });
            },
            clone: function (t, e) {
              var i = JSON.stringify(this.toJSON(e));
              this.cloneWithoutData(function (e) {
                e.loadFromJSON(i, function () {
                  t && t(e);
                });
              });
            },
            cloneWithoutData: function (t) {
              var e = n.util.createCanvasElement();
              (e.width = this.width), (e.height = this.height);
              var i = new n.Canvas(e);
              (i.clipTo = this.clipTo),
                this.backgroundImage
                  ? (i.setBackgroundImage(this.backgroundImage.src, function () {
                      i.renderAll(), t && t(i);
                    }),
                    (i.backgroundImageOpacity = this.backgroundImageOpacity),
                    (i.backgroundImageStretch = this.backgroundImageStretch))
                  : t && t(i);
            },
          }),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend,
              n = e.util.object.clone,
              r = e.util.toFixed,
              s = e.util.string.capitalize,
              o = e.util.degreesToRadians,
              a = e.StaticCanvas.supports("setLineDash"),
              h = !e.isLikelyNode,
              c = 2;
            e.Object ||
              ((e.Object = e.util.createClass(e.CommonMethods, {
                type: "object",
                originX: "left",
                originY: "top",
                top: 0,
                left: 0,
                width: 0,
                height: 0,
                scaleX: 1,
                scaleY: 1,
                flipX: !1,
                flipY: !1,
                opacity: 1,
                angle: 0,
                skewX: 0,
                skewY: 0,
                cornerSize: 13,
                transparentCorners: !0,
                hoverCursor: null,
                moveCursor: null,
                padding: 0,
                borderColor: "rgba(102,153,255,0.75)",
                borderDashArray: null,
                cornerColor: "rgba(102,153,255,0.5)",
                cornerStrokeColor: null,
                cornerStyle: "rect",
                cornerDashArray: null,
                centeredScaling: !1,
                centeredRotation: !0,
                fill: "rgb(0,0,0)",
                fillRule: "nonzero",
                globalCompositeOperation: "source-over",
                backgroundColor: "",
                selectionBackgroundColor: "",
                stroke: null,
                strokeWidth: 1,
                strokeDashArray: null,
                strokeDashOffset: 0,
                strokeLineCap: "butt",
                strokeLineJoin: "miter",
                strokeMiterLimit: 4,
                shadow: null,
                borderOpacityWhenMoving: 0.4,
                borderScaleFactor: 1,
                transformMatrix: null,
                minScaleLimit: 0,
                selectable: !0,
                evented: !0,
                visible: !0,
                hasControls: !0,
                hasBorders: !0,
                hasRotatingPoint: !0,
                rotatingPointOffset: 40,
                perPixelTargetFind: !1,
                includeDefaultValues: !0,
                clipTo: null,
                lockMovementX: !1,
                lockMovementY: !1,
                lockRotation: !1,
                lockScalingX: !1,
                lockScalingY: !1,
                lockUniScaling: !1,
                lockSkewingX: !1,
                lockSkewingY: !1,
                lockScalingFlip: !1,
                excludeFromExport: !1,
                objectCaching: h,
                statefullCache: !1,
                noScaleCache: !0,
                strokeUniform: !1,
                dirty: !0,
                __corner: 0,
                paintFirst: "fill",
                stateProperties:
                  "top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow clipTo visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(
                    " "
                  ),
                cacheProperties:
                  "fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(
                    " "
                  ),
                clipPath: void 0,
                inverted: !1,
                absolutePositioned: !1,
                initialize: function (t) {
                  t && this.setOptions(t);
                },
                _createCacheCanvas: function () {
                  (this._cacheProperties = {}),
                    (this._cacheCanvas = e.util.createCanvasElement()),
                    (this._cacheContext = this._cacheCanvas.getContext("2d")),
                    this._updateCacheCanvas(),
                    (this.dirty = !0);
                },
                _limitCacheSize: function (t) {
                  var i = e.perfLimitSizeTotal,
                    n = t.width,
                    r = t.height,
                    s = e.maxCacheSideLimit,
                    o = e.minCacheSideLimit;
                  if (n <= s && r <= s && n * r <= i)
                    return n < o && (t.width = o), r < o && (t.height = o), t;
                  var a = n / r,
                    h = e.util.limitDimsByArea(a, i),
                    c = e.util.capValue,
                    l = c(o, h.x, s),
                    u = c(o, h.y, s);
                  return (
                    n > l && ((t.zoomX /= n / l), (t.width = l), (t.capped = !0)),
                    r > u && ((t.zoomY /= r / u), (t.height = u), (t.capped = !0)),
                    t
                  );
                },
                _getCacheCanvasDimensions: function () {
                  var t = this.getTotalObjectScaling(),
                    e = this._getNonTransformedDimensions(),
                    i = t.scaleX,
                    n = t.scaleY,
                    r = e.x * i,
                    s = e.y * n;
                  return { width: r + c, height: s + c, zoomX: i, zoomY: n, x: e.x, y: e.y };
                },
                _updateCacheCanvas: function () {
                  var t = this.canvas;
                  if (this.noScaleCache && t && t._currentTransform) {
                    var i = t._currentTransform.target,
                      n = t._currentTransform.action;
                    if (this === i && n.slice && "scale" === n.slice(0, 5)) return !1;
                  }
                  var r,
                    s,
                    o = this._cacheCanvas,
                    a = this._limitCacheSize(this._getCacheCanvasDimensions()),
                    h = e.minCacheSideLimit,
                    c = a.width,
                    l = a.height,
                    u = a.zoomX,
                    f = a.zoomY,
                    d = c !== this.cacheWidth || l !== this.cacheHeight,
                    g = this.zoomX !== u || this.zoomY !== f,
                    p = d || g,
                    m = 0,
                    v = 0,
                    _ = !1;
                  if (d) {
                    var y = this._cacheCanvas.width,
                      b = this._cacheCanvas.height,
                      x = c > y || l > b,
                      C = (c < 0.9 * y || l < 0.9 * b) && y > h && b > h;
                    (_ = x || C),
                      x && !a.capped && (c > h || l > h) && ((m = 0.1 * c), (v = 0.1 * l));
                  }
                  return (
                    !!p &&
                    (_
                      ? ((o.width = Math.ceil(c + m)), (o.height = Math.ceil(l + v)))
                      : (this._cacheContext.setTransform(1, 0, 0, 1, 0, 0),
                        this._cacheContext.clearRect(0, 0, o.width, o.height)),
                    (r = (a.x * u) / 2),
                    (s = (a.y * f) / 2),
                    (this.cacheTranslationX = Math.round(o.width / 2 - r) + r),
                    (this.cacheTranslationY = Math.round(o.height / 2 - s) + s),
                    (this.cacheWidth = c),
                    (this.cacheHeight = l),
                    this._cacheContext.translate(this.cacheTranslationX, this.cacheTranslationY),
                    this._cacheContext.scale(u, f),
                    (this.zoomX = u),
                    (this.zoomY = f),
                    !0)
                  );
                },
                setOptions: function (t) {
                  this._setOptions(t),
                    this._initGradient(t.fill, "fill"),
                    this._initGradient(t.stroke, "stroke"),
                    this._initClipping(t),
                    this._initPattern(t.fill, "fill"),
                    this._initPattern(t.stroke, "stroke");
                },
                transform: function (t) {
                  var e;
                  (e =
                    this.group && !this.group._transformDone
                      ? this.calcTransformMatrix()
                      : this.calcOwnMatrix()),
                    t.transform(e[0], e[1], e[2], e[3], e[4], e[5]);
                },
                toObject: function (t) {
                  var i = e.Object.NUM_FRACTION_DIGITS,
                    n = {
                      type: this.type,
                      version: e.version,
                      originX: this.originX,
                      originY: this.originY,
                      left: r(this.left, i),
                      top: r(this.top, i),
                      width: r(this.width, i),
                      height: r(this.height, i),
                      fill: this.fill && this.fill.toObject ? this.fill.toObject() : this.fill,
                      stroke:
                        this.stroke && this.stroke.toObject ? this.stroke.toObject() : this.stroke,
                      strokeWidth: r(this.strokeWidth, i),
                      strokeDashArray: this.strokeDashArray
                        ? this.strokeDashArray.concat()
                        : this.strokeDashArray,
                      strokeLineCap: this.strokeLineCap,
                      strokeDashOffset: this.strokeDashOffset,
                      strokeLineJoin: this.strokeLineJoin,
                      strokeMiterLimit: r(this.strokeMiterLimit, i),
                      scaleX: r(this.scaleX, i),
                      scaleY: r(this.scaleY, i),
                      angle: r(this.angle, i),
                      flipX: this.flipX,
                      flipY: this.flipY,
                      opacity: r(this.opacity, i),
                      shadow:
                        this.shadow && this.shadow.toObject ? this.shadow.toObject() : this.shadow,
                      visible: this.visible,
                      clipTo: this.clipTo && String(this.clipTo),
                      backgroundColor: this.backgroundColor,
                      fillRule: this.fillRule,
                      paintFirst: this.paintFirst,
                      globalCompositeOperation: this.globalCompositeOperation,
                      transformMatrix: this.transformMatrix ? this.transformMatrix.concat() : null,
                      skewX: r(this.skewX, i),
                      skewY: r(this.skewY, i),
                    };
                  return (
                    this.clipPath &&
                      ((n.clipPath = this.clipPath.toObject(t)),
                      (n.clipPath.inverted = this.clipPath.inverted),
                      (n.clipPath.absolutePositioned = this.clipPath.absolutePositioned)),
                    e.util.populateWithProperties(this, n, t),
                    this.includeDefaultValues || (n = this._removeDefaultValues(n)),
                    n
                  );
                },
                toDatalessObject: function (t) {
                  return this.toObject(t);
                },
                _removeDefaultValues: function (t) {
                  var i = e.util.getKlass(t.type).prototype,
                    n = i.stateProperties;
                  return (
                    n.forEach(function (e) {
                      t[e] === i[e] && delete t[e];
                      var n =
                        "[object Array]" === Object.prototype.toString.call(t[e]) &&
                        "[object Array]" === Object.prototype.toString.call(i[e]);
                      n && 0 === t[e].length && 0 === i[e].length && delete t[e];
                    }),
                    t
                  );
                },
                toString: function () {
                  return "#<fabric." + s(this.type) + ">";
                },
                getObjectScaling: function () {
                  var t = this.scaleX,
                    e = this.scaleY;
                  if (this.group) {
                    var i = this.group.getObjectScaling();
                    (t *= i.scaleX), (e *= i.scaleY);
                  }
                  return { scaleX: t, scaleY: e };
                },
                getTotalObjectScaling: function () {
                  var t = this.getObjectScaling(),
                    e = t.scaleX,
                    i = t.scaleY;
                  if (this.canvas) {
                    var n = this.canvas.getZoom(),
                      r = this.canvas.getRetinaScaling();
                    (e *= n * r), (i *= n * r);
                  }
                  return { scaleX: e, scaleY: i };
                },
                getObjectOpacity: function () {
                  var t = this.opacity;
                  return this.group && (t *= this.group.getObjectOpacity()), t;
                },
                _set: function (t, i) {
                  var n = "scaleX" === t || "scaleY" === t,
                    r = this[t] !== i,
                    s = !1;
                  return (
                    n && (i = this._constrainScale(i)),
                    "scaleX" === t && i < 0
                      ? ((this.flipX = !this.flipX), (i *= -1))
                      : "scaleY" === t && i < 0
                      ? ((this.flipY = !this.flipY), (i *= -1))
                      : "shadow" !== t || !i || i instanceof e.Shadow
                      ? "dirty" === t && this.group && this.group.set("dirty", i)
                      : (i = new e.Shadow(i)),
                    (this[t] = i),
                    r &&
                      ((s = this.group && this.group.isOnACache()),
                      this.cacheProperties.indexOf(t) > -1
                        ? ((this.dirty = !0), s && this.group.set("dirty", !0))
                        : s && this.stateProperties.indexOf(t) > -1 && this.group.set("dirty", !0)),
                    this
                  );
                },
                setOnGroup: function () {},
                getViewportTransform: function () {
                  return this.canvas && this.canvas.viewportTransform
                    ? this.canvas.viewportTransform
                    : e.iMatrix.concat();
                },
                isNotVisible: function () {
                  return (
                    0 === this.opacity ||
                    (0 === this.width && 0 === this.height && 0 === this.strokeWidth) ||
                    !this.visible
                  );
                },
                render: function (t) {
                  this.isNotVisible() ||
                    (this.canvas &&
                      this.canvas.skipOffscreen &&
                      !this.group &&
                      !this.isOnScreen()) ||
                    (t.save(),
                    this._setupCompositeOperation(t),
                    this.drawSelectionBackground(t),
                    this.transform(t),
                    this._setOpacity(t),
                    this._setShadow(t, this),
                    this.transformMatrix && t.transform.apply(t, this.transformMatrix),
                    this.clipTo && e.util.clipContext(this, t),
                    this.shouldCache()
                      ? (this.renderCache(), this.drawCacheOnCanvas(t))
                      : (this._removeCacheCanvas(),
                        (this.dirty = !1),
                        this.drawObject(t),
                        this.objectCaching &&
                          this.statefullCache &&
                          this.saveState({ propertySet: "cacheProperties" })),
                    this.clipTo && t.restore(),
                    t.restore());
                },
                renderCache: function (t) {
                  (t = t || {}),
                    this._cacheCanvas || this._createCacheCanvas(),
                    this.isCacheDirty() &&
                      (this.statefullCache && this.saveState({ propertySet: "cacheProperties" }),
                      this.drawObject(this._cacheContext, t.forClipping),
                      (this.dirty = !1));
                },
                _removeCacheCanvas: function () {
                  (this._cacheCanvas = null), (this.cacheWidth = 0), (this.cacheHeight = 0);
                },
                needsItsOwnCache: function () {
                  return (
                    ("stroke" === this.paintFirst && "object" === typeof this.shadow) ||
                    !!this.clipPath
                  );
                },
                shouldCache: function () {
                  return (
                    (this.ownCaching =
                      this.objectCaching &&
                      (!this.group || this.needsItsOwnCache() || !this.group.isOnACache())),
                    this.ownCaching
                  );
                },
                willDrawShadow: function () {
                  return !!this.shadow && (0 !== this.shadow.offsetX || 0 !== this.shadow.offsetY);
                },
                drawClipPathOnCache: function (t) {
                  var i = this.clipPath;
                  if (
                    (t.save(),
                    i.inverted
                      ? (t.globalCompositeOperation = "destination-out")
                      : (t.globalCompositeOperation = "destination-in"),
                    i.absolutePositioned)
                  ) {
                    var n = e.util.invertTransform(this.calcTransformMatrix());
                    t.transform(n[0], n[1], n[2], n[3], n[4], n[5]);
                  }
                  i.transform(t),
                    t.scale(1 / i.zoomX, 1 / i.zoomY),
                    t.drawImage(i._cacheCanvas, -i.cacheTranslationX, -i.cacheTranslationY),
                    t.restore();
                },
                drawObject: function (t, e) {
                  var i = this.fill,
                    n = this.stroke;
                  e
                    ? ((this.fill = "black"), (this.stroke = ""), this._setClippingProperties(t))
                    : (this._renderBackground(t),
                      this._setStrokeStyles(t, this),
                      this._setFillStyles(t, this)),
                    this._render(t),
                    this._drawClipPath(t),
                    (this.fill = i),
                    (this.stroke = n);
                },
                _drawClipPath: function (t) {
                  var e = this.clipPath;
                  e &&
                    ((e.canvas = this.canvas),
                    e.shouldCache(),
                    (e._transformDone = !0),
                    e.renderCache({ forClipping: !0 }),
                    this.drawClipPathOnCache(t));
                },
                drawCacheOnCanvas: function (t) {
                  t.scale(1 / this.zoomX, 1 / this.zoomY),
                    t.drawImage(
                      this._cacheCanvas,
                      -this.cacheTranslationX,
                      -this.cacheTranslationY
                    );
                },
                isCacheDirty: function (t) {
                  if (this.isNotVisible()) return !1;
                  if (this._cacheCanvas && !t && this._updateCacheCanvas()) return !0;
                  if (
                    this.dirty ||
                    (this.clipPath && this.clipPath.absolutePositioned) ||
                    (this.statefullCache && this.hasStateChanged("cacheProperties"))
                  ) {
                    if (this._cacheCanvas && !t) {
                      var e = this.cacheWidth / this.zoomX,
                        i = this.cacheHeight / this.zoomY;
                      this._cacheContext.clearRect(-e / 2, -i / 2, e, i);
                    }
                    return !0;
                  }
                  return !1;
                },
                _renderBackground: function (t) {
                  if (this.backgroundColor) {
                    var e = this._getNonTransformedDimensions();
                    (t.fillStyle = this.backgroundColor),
                      t.fillRect(-e.x / 2, -e.y / 2, e.x, e.y),
                      this._removeShadow(t);
                  }
                },
                _setOpacity: function (t) {
                  this.group && !this.group._transformDone
                    ? (t.globalAlpha = this.getObjectOpacity())
                    : (t.globalAlpha *= this.opacity);
                },
                _setStrokeStyles: function (t, e) {
                  e.stroke &&
                    ((t.lineWidth = e.strokeWidth),
                    (t.lineCap = e.strokeLineCap),
                    (t.lineDashOffset = e.strokeDashOffset),
                    (t.lineJoin = e.strokeLineJoin),
                    (t.miterLimit = e.strokeMiterLimit),
                    (t.strokeStyle = e.stroke.toLive ? e.stroke.toLive(t, this) : e.stroke));
                },
                _setFillStyles: function (t, e) {
                  e.fill && (t.fillStyle = e.fill.toLive ? e.fill.toLive(t, this) : e.fill);
                },
                _setClippingProperties: function (t) {
                  (t.globalAlpha = 1), (t.strokeStyle = "transparent"), (t.fillStyle = "#000000");
                },
                _setLineDash: function (t, e, i) {
                  e &&
                    (1 & e.length && e.push.apply(e, e),
                    a ? t.setLineDash(e) : i && i(t),
                    this.strokeUniform &&
                      t.setLineDash(
                        t.getLineDash().map(function (e) {
                          return e * t.lineWidth;
                        })
                      ));
                },
                _renderControls: function (t, i) {
                  var n,
                    r,
                    s,
                    a = this.getViewportTransform(),
                    h = this.calcTransformMatrix();
                  (i = i || {}),
                    (r = "undefined" !== typeof i.hasBorders ? i.hasBorders : this.hasBorders),
                    (s = "undefined" !== typeof i.hasControls ? i.hasControls : this.hasControls),
                    (h = e.util.multiplyTransformMatrices(a, h)),
                    (n = e.util.qrDecompose(h)),
                    t.save(),
                    t.translate(n.translateX, n.translateY),
                    (t.lineWidth = 1 * this.borderScaleFactor),
                    this.group ||
                      (t.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1),
                    i.forActiveSelection
                      ? (t.rotate(o(n.angle)), r && this.drawBordersInGroup(t, n, i))
                      : (t.rotate(o(this.angle)), r && this.drawBorders(t, i)),
                    s && this.drawControls(t, i),
                    t.restore();
                },
                _setShadow: function (t) {
                  if (this.shadow) {
                    var i = this.shadow,
                      n = this.canvas,
                      r = (n && n.viewportTransform[0]) || 1,
                      s = (n && n.viewportTransform[3]) || 1,
                      o = this.getObjectScaling();
                    n &&
                      n._isRetinaScaling() &&
                      ((r *= e.devicePixelRatio), (s *= e.devicePixelRatio)),
                      (t.shadowColor = i.color),
                      (t.shadowBlur =
                        (i.blur * e.browserShadowBlurConstant * (r + s) * (o.scaleX + o.scaleY)) /
                        4),
                      (t.shadowOffsetX = i.offsetX * r * o.scaleX),
                      (t.shadowOffsetY = i.offsetY * s * o.scaleY);
                  }
                },
                _removeShadow: function (t) {
                  this.shadow &&
                    ((t.shadowColor = ""), (t.shadowBlur = t.shadowOffsetX = t.shadowOffsetY = 0));
                },
                _applyPatternGradientTransform: function (t, e) {
                  if (!e || !e.toLive) return { offsetX: 0, offsetY: 0 };
                  var i = e.gradientTransform || e.patternTransform,
                    n = -this.width / 2 + e.offsetX || 0,
                    r = -this.height / 2 + e.offsetY || 0;
                  return (
                    t.translate(n, r),
                    i && t.transform(i[0], i[1], i[2], i[3], i[4], i[5]),
                    { offsetX: n, offsetY: r }
                  );
                },
                _renderPaintInOrder: function (t) {
                  "stroke" === this.paintFirst
                    ? (this._renderStroke(t), this._renderFill(t))
                    : (this._renderFill(t), this._renderStroke(t));
                },
                _renderFill: function (t) {
                  this.fill &&
                    (t.save(),
                    this._applyPatternGradientTransform(t, this.fill),
                    "evenodd" === this.fillRule ? t.fill("evenodd") : t.fill(),
                    t.restore());
                },
                _renderStroke: function (t) {
                  this.stroke &&
                    0 !== this.strokeWidth &&
                    (this.shadow && !this.shadow.affectStroke && this._removeShadow(t),
                    t.save(),
                    this.strokeUniform && t.scale(1 / this.scaleX, 1 / this.scaleY),
                    this._setLineDash(t, this.strokeDashArray, this._renderDashedStroke),
                    this._applyPatternGradientTransform(t, this.stroke),
                    t.stroke(),
                    t.restore());
                },
                _findCenterFromElement: function () {
                  return { x: this.left + this.width / 2, y: this.top + this.height / 2 };
                },
                _assignTransformMatrixProps: function () {
                  if (this.transformMatrix) {
                    var t = e.util.qrDecompose(this.transformMatrix);
                    (this.flipX = !1),
                      (this.flipY = !1),
                      this.set("scaleX", t.scaleX),
                      this.set("scaleY", t.scaleY),
                      (this.angle = t.angle),
                      (this.skewX = t.skewX),
                      (this.skewY = 0);
                  }
                },
                _removeTransformMatrix: function (t) {
                  var i = this._findCenterFromElement();
                  this.transformMatrix &&
                    (this._assignTransformMatrixProps(),
                    (i = e.util.transformPoint(i, this.transformMatrix))),
                    (this.transformMatrix = null),
                    t &&
                      ((this.scaleX *= t.scaleX),
                      (this.scaleY *= t.scaleY),
                      (this.cropX = t.cropX),
                      (this.cropY = t.cropY),
                      (i.x += t.offsetLeft),
                      (i.y += t.offsetTop),
                      (this.width = t.width),
                      (this.height = t.height)),
                    this.setPositionByOrigin(i, "center", "center");
                },
                clone: function (t, i) {
                  var n = this.toObject(i);
                  this.constructor.fromObject
                    ? this.constructor.fromObject(n, t)
                    : e.Object._fromObject("Object", n, t);
                },
                cloneAsImage: function (t, i) {
                  var n = this.toCanvasElement(i);
                  return t && t(new e.Image(n)), this;
                },
                toCanvasElement: function (t) {
                  t || (t = {});
                  var i = e.util,
                    n = i.saveObjectTransform(this),
                    r = this.shadow,
                    s = Math.abs,
                    o = (t.multiplier || 1) * (t.enableRetinaScaling ? e.devicePixelRatio : 1);
                  t.withoutTransform && i.resetObjectTransform(this),
                    t.withoutShadow && (this.shadow = null);
                  var a,
                    h,
                    c = e.util.createCanvasElement(),
                    l = this.getBoundingRect(!0, !0),
                    u = this.shadow,
                    f = { x: 0, y: 0 };
                  u &&
                    ((h = u.blur),
                    (a = this.getObjectScaling()),
                    (f.x = 2 * Math.round((s(u.offsetX) + h) * s(a.scaleX))),
                    (f.y = 2 * Math.round((s(u.offsetY) + h) * s(a.scaleY)))),
                    (c.width = l.width + f.x),
                    (c.height = l.height + f.y),
                    (c.width += c.width % 2 ? 2 - (c.width % 2) : 0),
                    (c.height += c.height % 2 ? 2 - (c.height % 2) : 0);
                  var d = new e.StaticCanvas(c, {
                    enableRetinaScaling: !1,
                    renderOnAddRemove: !1,
                    skipOffscreen: !1,
                  });
                  "jpeg" === t.format && (d.backgroundColor = "#fff"),
                    this.setPositionByOrigin(
                      new e.Point(d.width / 2, d.height / 2),
                      "center",
                      "center"
                    );
                  var g = this.canvas;
                  d.add(this);
                  var p = d.toCanvasElement(o || 1, t);
                  return (
                    (this.shadow = r),
                    (this.canvas = g),
                    this.set(n).setCoords(),
                    (d._objects = []),
                    d.dispose(),
                    (d = null),
                    p
                  );
                },
                toDataURL: function (t) {
                  return (
                    t || (t = {}),
                    e.util.toDataURL(this.toCanvasElement(t), t.format || "png", t.quality || 1)
                  );
                },
                isType: function (t) {
                  return this.type === t;
                },
                complexity: function () {
                  return 1;
                },
                toJSON: function (t) {
                  return this.toObject(t);
                },
                setGradient: function (t, i) {
                  i || (i = {});
                  var n = { colorStops: [] };
                  return (
                    (n.type = i.type || (i.r1 || i.r2 ? "radial" : "linear")),
                    (n.coords = { x1: i.x1, y1: i.y1, x2: i.x2, y2: i.y2 }),
                    (i.r1 || i.r2) && ((n.coords.r1 = i.r1), (n.coords.r2 = i.r2)),
                    (n.gradientTransform = i.gradientTransform),
                    e.Gradient.prototype.addColorStop.call(n, i.colorStops),
                    this.set(t, e.Gradient.forObject(this, n))
                  );
                },
                setPatternFill: function (t, i) {
                  return this.set("fill", new e.Pattern(t, i));
                },
                setShadow: function (t) {
                  return this.set("shadow", t ? new e.Shadow(t) : null);
                },
                setColor: function (t) {
                  return this.set("fill", t), this;
                },
                rotate: function (t) {
                  var e =
                    ("center" !== this.originX || "center" !== this.originY) &&
                    this.centeredRotation;
                  return (
                    e && this._setOriginToCenter(),
                    this.set("angle", t),
                    e && this._resetOrigin(),
                    this
                  );
                },
                centerH: function () {
                  return this.canvas && this.canvas.centerObjectH(this), this;
                },
                viewportCenterH: function () {
                  return this.canvas && this.canvas.viewportCenterObjectH(this), this;
                },
                centerV: function () {
                  return this.canvas && this.canvas.centerObjectV(this), this;
                },
                viewportCenterV: function () {
                  return this.canvas && this.canvas.viewportCenterObjectV(this), this;
                },
                center: function () {
                  return this.canvas && this.canvas.centerObject(this), this;
                },
                viewportCenter: function () {
                  return this.canvas && this.canvas.viewportCenterObject(this), this;
                },
                getLocalPointer: function (t, i) {
                  i = i || this.canvas.getPointer(t);
                  var n = new e.Point(i.x, i.y),
                    r = this._getLeftTopCoords();
                  return (
                    this.angle && (n = e.util.rotatePoint(n, r, o(-this.angle))),
                    { x: n.x - r.x, y: n.y - r.y }
                  );
                },
                _setupCompositeOperation: function (t) {
                  this.globalCompositeOperation &&
                    (t.globalCompositeOperation = this.globalCompositeOperation);
                },
              })),
              e.util.createAccessors && e.util.createAccessors(e.Object),
              i(e.Object.prototype, e.Observable),
              (e.Object.NUM_FRACTION_DIGITS = 2),
              (e.Object._fromObject = function (t, i, r, s) {
                var o = e[t];
                (i = n(i, !0)),
                  e.util.enlivenPatterns([i.fill, i.stroke], function (t) {
                    "undefined" !== typeof t[0] && (i.fill = t[0]),
                      "undefined" !== typeof t[1] && (i.stroke = t[1]),
                      e.util.enlivenObjects([i.clipPath], function (t) {
                        i.clipPath = t[0];
                        var e = s ? new o(i[s], i) : new o(i);
                        r && r(e);
                      });
                  });
              }),
              (e.Object.__uid = 0));
          })(e),
          (function () {
            var t = n.util.degreesToRadians,
              e = { left: -0.5, center: 0, right: 0.5 },
              i = { top: -0.5, center: 0, bottom: 0.5 };
            n.util.object.extend(n.Object.prototype, {
              translateToGivenOrigin: function (t, r, s, o, a) {
                var h,
                  c,
                  l,
                  u = t.x,
                  f = t.y;
                return (
                  "string" === typeof r ? (r = e[r]) : (r -= 0.5),
                  "string" === typeof o ? (o = e[o]) : (o -= 0.5),
                  (h = o - r),
                  "string" === typeof s ? (s = i[s]) : (s -= 0.5),
                  "string" === typeof a ? (a = i[a]) : (a -= 0.5),
                  (c = a - s),
                  (h || c) &&
                    ((l = this._getTransformedDimensions()),
                    (u = t.x + h * l.x),
                    (f = t.y + c * l.y)),
                  new n.Point(u, f)
                );
              },
              translateToCenterPoint: function (e, i, r) {
                var s = this.translateToGivenOrigin(e, i, r, "center", "center");
                return this.angle ? n.util.rotatePoint(s, e, t(this.angle)) : s;
              },
              translateToOriginPoint: function (e, i, r) {
                var s = this.translateToGivenOrigin(e, "center", "center", i, r);
                return this.angle ? n.util.rotatePoint(s, e, t(this.angle)) : s;
              },
              getCenterPoint: function () {
                var t = new n.Point(this.left, this.top);
                return this.translateToCenterPoint(t, this.originX, this.originY);
              },
              getPointByOrigin: function (t, e) {
                var i = this.getCenterPoint();
                return this.translateToOriginPoint(i, t, e);
              },
              toLocalPoint: function (e, i, r) {
                var s,
                  o,
                  a = this.getCenterPoint();
                return (
                  (s =
                    "undefined" !== typeof i && "undefined" !== typeof r
                      ? this.translateToGivenOrigin(a, "center", "center", i, r)
                      : new n.Point(this.left, this.top)),
                  (o = new n.Point(e.x, e.y)),
                  this.angle && (o = n.util.rotatePoint(o, a, -t(this.angle))),
                  o.subtractEquals(s)
                );
              },
              setPositionByOrigin: function (t, e, i) {
                var n = this.translateToCenterPoint(t, e, i),
                  r = this.translateToOriginPoint(n, this.originX, this.originY);
                this.set("left", r.x), this.set("top", r.y);
              },
              adjustPosition: function (i) {
                var r,
                  s,
                  o = t(this.angle),
                  a = this.getScaledWidth(),
                  h = n.util.cos(o) * a,
                  c = n.util.sin(o) * a;
                (r = "string" === typeof this.originX ? e[this.originX] : this.originX - 0.5),
                  (s = "string" === typeof i ? e[i] : i - 0.5),
                  (this.left += h * (s - r)),
                  (this.top += c * (s - r)),
                  this.setCoords(),
                  (this.originX = i);
              },
              _setOriginToCenter: function () {
                (this._originalOriginX = this.originX), (this._originalOriginY = this.originY);
                var t = this.getCenterPoint();
                (this.originX = "center"),
                  (this.originY = "center"),
                  (this.left = t.x),
                  (this.top = t.y);
              },
              _resetOrigin: function () {
                var t = this.translateToOriginPoint(
                  this.getCenterPoint(),
                  this._originalOriginX,
                  this._originalOriginY
                );
                (this.originX = this._originalOriginX),
                  (this.originY = this._originalOriginY),
                  (this.left = t.x),
                  (this.top = t.y),
                  (this._originalOriginX = null),
                  (this._originalOriginY = null);
              },
              _getLeftTopCoords: function () {
                return this.translateToOriginPoint(this.getCenterPoint(), "left", "top");
              },
            });
          })(),
          (function () {
            function t(t) {
              return [
                new n.Point(t.tl.x, t.tl.y),
                new n.Point(t.tr.x, t.tr.y),
                new n.Point(t.br.x, t.br.y),
                new n.Point(t.bl.x, t.bl.y),
              ];
            }
            var e = n.util.degreesToRadians,
              i = n.util.multiplyTransformMatrices,
              r = n.util.transformPoint;
            n.util.object.extend(n.Object.prototype, {
              oCoords: null,
              aCoords: null,
              ownMatrixCache: null,
              matrixCache: null,
              getCoords: function (e, i) {
                this.oCoords || this.setCoords();
                var n = e ? this.aCoords : this.oCoords;
                return t(i ? this.calcCoords(e) : n);
              },
              intersectsWithRect: function (t, e, i, r) {
                var s = this.getCoords(i, r),
                  o = n.Intersection.intersectPolygonRectangle(s, t, e);
                return "Intersection" === o.status;
              },
              intersectsWithObject: function (t, e, i) {
                var r = n.Intersection.intersectPolygonPolygon(
                  this.getCoords(e, i),
                  t.getCoords(e, i)
                );
                return (
                  "Intersection" === r.status ||
                  t.isContainedWithinObject(this, e, i) ||
                  this.isContainedWithinObject(t, e, i)
                );
              },
              isContainedWithinObject: function (t, e, i) {
                for (
                  var n = this.getCoords(e, i),
                    r = 0,
                    s = t._getImageLines(i ? t.calcCoords(e) : e ? t.aCoords : t.oCoords);
                  r < 4;
                  r++
                )
                  if (!t.containsPoint(n[r], s)) return !1;
                return !0;
              },
              isContainedWithinRect: function (t, e, i, n) {
                var r = this.getBoundingRect(i, n);
                return (
                  r.left >= t.x &&
                  r.left + r.width <= e.x &&
                  r.top >= t.y &&
                  r.top + r.height <= e.y
                );
              },
              containsPoint: function (t, e, i, n) {
                e =
                  e ||
                  this._getImageLines(n ? this.calcCoords(i) : i ? this.aCoords : this.oCoords);
                var r = this._findCrossPoints(t, e);
                return 0 !== r && r % 2 === 1;
              },
              isOnScreen: function (t) {
                if (!this.canvas) return !1;
                for (
                  var e,
                    i = this.canvas.vptCoords.tl,
                    n = this.canvas.vptCoords.br,
                    r = this.getCoords(!0, t),
                    s = 0;
                  s < 4;
                  s++
                )
                  if (((e = r[s]), e.x <= n.x && e.x >= i.x && e.y <= n.y && e.y >= i.y)) return !0;
                return (
                  !!this.intersectsWithRect(i, n, !0, t) || this._containsCenterOfCanvas(i, n, t)
                );
              },
              _containsCenterOfCanvas: function (t, e, i) {
                var n = { x: (t.x + e.x) / 2, y: (t.y + e.y) / 2 };
                return !!this.containsPoint(n, null, !0, i);
              },
              isPartiallyOnScreen: function (t) {
                if (!this.canvas) return !1;
                var e = this.canvas.vptCoords.tl,
                  i = this.canvas.vptCoords.br;
                return (
                  !!this.intersectsWithRect(e, i, !0, t) || this._containsCenterOfCanvas(e, i, t)
                );
              },
              _getImageLines: function (t) {
                return {
                  topline: { o: t.tl, d: t.tr },
                  rightline: { o: t.tr, d: t.br },
                  bottomline: { o: t.br, d: t.bl },
                  leftline: { o: t.bl, d: t.tl },
                };
              },
              _findCrossPoints: function (t, e) {
                var i,
                  n,
                  r,
                  s,
                  o,
                  a,
                  h = 0;
                for (var c in e)
                  if (
                    ((a = e[c]),
                    !(a.o.y < t.y && a.d.y < t.y) &&
                      !(a.o.y >= t.y && a.d.y >= t.y) &&
                      (a.o.x === a.d.x && a.o.x >= t.x
                        ? (o = a.o.x)
                        : ((i = 0),
                          (n = (a.d.y - a.o.y) / (a.d.x - a.o.x)),
                          (r = t.y - i * t.x),
                          (s = a.o.y - n * a.o.x),
                          (o = -(r - s) / (i - n))),
                      o >= t.x && (h += 1),
                      2 === h))
                  )
                    break;
                return h;
              },
              getBoundingRect: function (t, e) {
                var i = this.getCoords(t, e);
                return n.util.makeBoundingBoxFromPoints(i);
              },
              getScaledWidth: function () {
                return this._getTransformedDimensions().x;
              },
              getScaledHeight: function () {
                return this._getTransformedDimensions().y;
              },
              _constrainScale: function (t) {
                return Math.abs(t) < this.minScaleLimit
                  ? t < 0
                    ? -this.minScaleLimit
                    : this.minScaleLimit
                  : 0 === t
                  ? 1e-4
                  : t;
              },
              scale: function (t) {
                return this._set("scaleX", t), this._set("scaleY", t), this.setCoords();
              },
              scaleToWidth: function (t, e) {
                var i = this.getBoundingRect(e).width / this.getScaledWidth();
                return this.scale(t / this.width / i);
              },
              scaleToHeight: function (t, e) {
                var i = this.getBoundingRect(e).height / this.getScaledHeight();
                return this.scale(t / this.height / i);
              },
              calcCoords: function (t) {
                var s = this._calcRotateMatrix(),
                  o = this._calcTranslateMatrix(),
                  a = i(o, s),
                  h = this.getViewportTransform(),
                  c = t ? a : i(h, a),
                  l = this._getTransformedDimensions(),
                  u = l.x / 2,
                  f = l.y / 2,
                  d = r({ x: -u, y: -f }, c),
                  g = r({ x: u, y: -f }, c),
                  p = r({ x: -u, y: f }, c),
                  m = r({ x: u, y: f }, c);
                if (!t) {
                  var v = this.padding,
                    _ = e(this.angle),
                    y = n.util.cos(_),
                    b = n.util.sin(_),
                    x = y * v,
                    C = b * v,
                    w = x + C,
                    S = x - C;
                  v &&
                    ((d.x -= S),
                    (d.y -= w),
                    (g.x += w),
                    (g.y -= S),
                    (p.x -= w),
                    (p.y += S),
                    (m.x += S),
                    (m.y += w));
                  var T = new n.Point((d.x + p.x) / 2, (d.y + p.y) / 2),
                    O = new n.Point((g.x + d.x) / 2, (g.y + d.y) / 2),
                    k = new n.Point((m.x + g.x) / 2, (m.y + g.y) / 2),
                    E = new n.Point((m.x + p.x) / 2, (m.y + p.y) / 2),
                    P = new n.Point(
                      O.x + b * this.rotatingPointOffset,
                      O.y - y * this.rotatingPointOffset
                    );
                }
                var D = { tl: d, tr: g, br: m, bl: p };
                return t || ((D.ml = T), (D.mt = O), (D.mr = k), (D.mb = E), (D.mtr = P)), D;
              },
              setCoords: function (t, e) {
                return (
                  (this.oCoords = this.calcCoords(t)),
                  e || (this.aCoords = this.calcCoords(!0)),
                  t || (this._setCornerCoords && this._setCornerCoords()),
                  this
                );
              },
              _calcRotateMatrix: function () {
                if (this.angle) {
                  var t = e(this.angle),
                    i = n.util.cos(t),
                    r = n.util.sin(t);
                  return [i, r, -r, i, 0, 0];
                }
                return n.iMatrix.concat();
              },
              _calcTranslateMatrix: function () {
                var t = this.getCenterPoint();
                return [1, 0, 0, 1, t.x, t.y];
              },
              transformMatrixKey: function (t) {
                var e = "_",
                  i = "";
                return (
                  !t && this.group && (i = this.group.transformMatrixKey(t) + e),
                  i +
                    this.top +
                    e +
                    this.left +
                    e +
                    this.scaleX +
                    e +
                    this.scaleY +
                    e +
                    this.skewX +
                    e +
                    this.skewY +
                    e +
                    this.angle +
                    e +
                    this.originX +
                    e +
                    this.originY +
                    e +
                    this.width +
                    e +
                    this.height +
                    e +
                    this.strokeWidth +
                    this.flipX +
                    this.flipY
                );
              },
              calcTransformMatrix: function (t) {
                if (t) return this.calcOwnMatrix();
                var e = this.transformMatrixKey(),
                  n = this.matrixCache || (this.matrixCache = {});
                if (n.key === e) return n.value;
                var r = this.calcOwnMatrix();
                return (
                  this.group && (r = i(this.group.calcTransformMatrix(), r)),
                  (n.key = e),
                  (n.value = r),
                  r
                );
              },
              calcOwnMatrix: function () {
                var t = this.transformMatrixKey(!0),
                  e = this.ownMatrixCache || (this.ownMatrixCache = {});
                if (e.key === t) return e.value;
                var n,
                  r = this._calcTranslateMatrix(),
                  s = this._calcDimensionsTransformMatrix(this.skewX, this.skewY, !0);
                return (
                  this.angle && ((n = this._calcRotateMatrix()), (r = i(r, n))),
                  (r = i(r, s)),
                  (e.key = t),
                  (e.value = r),
                  r
                );
              },
              _calcDimensionsTransformMatrix: function (t, n, r) {
                var s,
                  o = this.scaleX * (r && this.flipX ? -1 : 1),
                  a = this.scaleY * (r && this.flipY ? -1 : 1),
                  h = [o, 0, 0, a, 0, 0];
                return (
                  t && ((s = [1, 0, Math.tan(e(t)), 1]), (h = i(h, s, !0))),
                  n && ((s = [1, Math.tan(e(n)), 0, 1]), (h = i(h, s, !0))),
                  h
                );
              },
              _getNonTransformedDimensions: function () {
                var t = this.strokeWidth,
                  e = this.width + t,
                  i = this.height + t;
                return { x: e, y: i };
              },
              _getTransformedDimensions: function (t, e) {
                "undefined" === typeof t && (t = this.skewX),
                  "undefined" === typeof e && (e = this.skewY);
                var i,
                  r,
                  s = this._getNonTransformedDimensions(),
                  o = 0 === t && 0 === e;
                if (
                  (this.strokeUniform
                    ? ((i = this.width), (r = this.height))
                    : ((i = s.x), (r = s.y)),
                  o)
                )
                  return this._finalizeDiemensions(i * this.scaleX, r * this.scaleY);
                (i /= 2), (r /= 2);
                var a,
                  h,
                  c = [
                    { x: -i, y: -r },
                    { x: i, y: -r },
                    { x: -i, y: r },
                    { x: i, y: r },
                  ],
                  l = this._calcDimensionsTransformMatrix(t, e, !1);
                for (a = 0; a < c.length; a++) c[a] = n.util.transformPoint(c[a], l);
                return (
                  (h = n.util.makeBoundingBoxFromPoints(c)),
                  this._finalizeDiemensions(h.width, h.height)
                );
              },
              _finalizeDiemensions: function (t, e) {
                return this.strokeUniform
                  ? { x: t + this.strokeWidth, y: e + this.strokeWidth }
                  : { x: t, y: e };
              },
              _calculateCurrentDimensions: function () {
                var t = this.getViewportTransform(),
                  e = this._getTransformedDimensions(),
                  i = n.util.transformPoint(e, t, !0);
                return i.scalarAdd(2 * this.padding);
              },
            });
          })(),
          n.util.object.extend(n.Object.prototype, {
            sendToBack: function () {
              return (
                this.group
                  ? n.StaticCanvas.prototype.sendToBack.call(this.group, this)
                  : this.canvas.sendToBack(this),
                this
              );
            },
            bringToFront: function () {
              return (
                this.group
                  ? n.StaticCanvas.prototype.bringToFront.call(this.group, this)
                  : this.canvas.bringToFront(this),
                this
              );
            },
            sendBackwards: function (t) {
              return (
                this.group
                  ? n.StaticCanvas.prototype.sendBackwards.call(this.group, this, t)
                  : this.canvas.sendBackwards(this, t),
                this
              );
            },
            bringForward: function (t) {
              return (
                this.group
                  ? n.StaticCanvas.prototype.bringForward.call(this.group, this, t)
                  : this.canvas.bringForward(this, t),
                this
              );
            },
            moveTo: function (t) {
              return (
                this.group && "activeSelection" !== this.group.type
                  ? n.StaticCanvas.prototype.moveTo.call(this.group, this, t)
                  : this.canvas.moveTo(this, t),
                this
              );
            },
          }),
          (function () {
            function t(t, e) {
              if (e) {
                if (e.toLive) return t + ": url(#SVGID_" + e.id + "); ";
                var i = new n.Color(e),
                  r = t + ": " + i.toRgb() + "; ",
                  s = i.getAlpha();
                return 1 !== s && (r += t + "-opacity: " + s.toString() + "; "), r;
              }
              return t + ": none; ";
            }
            var e = n.util.toFixed;
            n.util.object.extend(n.Object.prototype, {
              getSvgStyles: function (e) {
                var i = this.fillRule ? this.fillRule : "nonzero",
                  n = this.strokeWidth ? this.strokeWidth : "0",
                  r = this.strokeDashArray ? this.strokeDashArray.join(" ") : "none",
                  s = this.strokeDashOffset ? this.strokeDashOffset : "0",
                  o = this.strokeLineCap ? this.strokeLineCap : "butt",
                  a = this.strokeLineJoin ? this.strokeLineJoin : "miter",
                  h = this.strokeMiterLimit ? this.strokeMiterLimit : "4",
                  c = "undefined" !== typeof this.opacity ? this.opacity : "1",
                  l = this.visible ? "" : " visibility: hidden;",
                  u = e ? "" : this.getSvgFilter(),
                  f = t("fill", this.fill),
                  d = t("stroke", this.stroke);
                return [
                  d,
                  "stroke-width: ",
                  n,
                  "; ",
                  "stroke-dasharray: ",
                  r,
                  "; ",
                  "stroke-linecap: ",
                  o,
                  "; ",
                  "stroke-dashoffset: ",
                  s,
                  "; ",
                  "stroke-linejoin: ",
                  a,
                  "; ",
                  "stroke-miterlimit: ",
                  h,
                  "; ",
                  f,
                  "fill-rule: ",
                  i,
                  "; ",
                  "opacity: ",
                  c,
                  ";",
                  u,
                  l,
                ].join("");
              },
              getSvgSpanStyles: function (e, i) {
                var n = "; ",
                  r = e.fontFamily
                    ? "font-family: " +
                      (-1 === e.fontFamily.indexOf("'") && -1 === e.fontFamily.indexOf('"')
                        ? "'" + e.fontFamily + "'"
                        : e.fontFamily) +
                      n
                    : "",
                  s = e.strokeWidth ? "stroke-width: " + e.strokeWidth + n : "",
                  o = ((r = r), e.fontSize ? "font-size: " + e.fontSize + "px" + n : ""),
                  a = e.fontStyle ? "font-style: " + e.fontStyle + n : "",
                  h = e.fontWeight ? "font-weight: " + e.fontWeight + n : "",
                  c = e.fill ? t("fill", e.fill) : "",
                  l = e.stroke ? t("stroke", e.stroke) : "",
                  u = this.getSvgTextDecoration(e),
                  f = e.deltaY ? "baseline-shift: " + -e.deltaY + "; " : "";
                return (
                  u && (u = "text-decoration: " + u + n),
                  [l, s, r, o, a, h, u, c, f, i ? "white-space: pre; " : ""].join("")
                );
              },
              getSvgTextDecoration: function (t) {
                return "overline" in t || "underline" in t || "linethrough" in t
                  ? (t.overline ? "overline " : "") +
                      (t.underline ? "underline " : "") +
                      (t.linethrough ? "line-through " : "")
                  : "";
              },
              getSvgFilter: function () {
                return this.shadow ? "filter: url(#SVGID_" + this.shadow.id + ");" : "";
              },
              getSvgCommons: function () {
                return [
                  this.id ? 'id="' + this.id + '" ' : "",
                  this.clipPath ? 'clip-path="url(#' + this.clipPath.clipPathId + ')" ' : "",
                ].join("");
              },
              getSvgTransform: function (t, i) {
                var r = t ? this.calcTransformMatrix() : this.calcOwnMatrix(),
                  s = r
                    .map(function (t) {
                      return e(t, n.Object.NUM_FRACTION_DIGITS);
                    })
                    .join(" ");
                return (
                  'transform="matrix(' + s + ")" + (i || "") + this.getSvgTransformMatrix() + '" '
                );
              },
              getSvgTransformMatrix: function () {
                return this.transformMatrix
                  ? " matrix(" + this.transformMatrix.join(" ") + ")"
                  : "";
              },
              _setSVGBg: function (t) {
                if (this.backgroundColor) {
                  var i = n.Object.NUM_FRACTION_DIGITS;
                  t.push(
                    "\t\t<rect ",
                    this._getFillAttributes(this.backgroundColor),
                    ' x="',
                    e(-this.width / 2, i),
                    '" y="',
                    e(-this.height / 2, i),
                    '" width="',
                    e(this.width, i),
                    '" height="',
                    e(this.height, i),
                    '"></rect>\n'
                  );
                }
              },
              toSVG: function (t) {
                return this._createBaseSVGMarkup(this._toSVG(), { reviver: t });
              },
              toClipPathSVG: function (t) {
                return "\t" + this._createBaseClipPathSVGMarkup(this._toSVG(), { reviver: t });
              },
              _createBaseClipPathSVGMarkup: function (t, e) {
                e = e || {};
                var i = e.reviver,
                  n = e.additionalTransform || "",
                  r = [this.getSvgTransform(!0, n), this.getSvgCommons()].join(""),
                  s = t.indexOf("COMMON_PARTS");
                return (t[s] = r), i ? i(t.join("")) : t.join("");
              },
              _createBaseSVGMarkup: function (t, e) {
                e = e || {};
                var i,
                  r,
                  s = e.noStyle,
                  o = e.withShadow,
                  a = e.reviver,
                  h = s ? "" : 'style="' + this.getSvgStyles() + '" ',
                  c = o ? 'style="' + this.getSvgFilter() + '" ' : "",
                  l = this.clipPath,
                  u = this.strokeUniform ? 'vector-effect="non-scaling-stroke" ' : "",
                  f = this.clipPath && this.clipPath.absolutePositioned,
                  d = [],
                  g = t.indexOf("COMMON_PARTS"),
                  p = e.additionalTransform;
                return (
                  l &&
                    ((l.clipPathId = "CLIPPATH_" + n.Object.__uid++),
                    (r =
                      '<clipPath id="' +
                      l.clipPathId +
                      '" >\n' +
                      this.clipPath.toClipPathSVG(a) +
                      "</clipPath>\n")),
                  f && d.push("<g ", c, this.getSvgCommons(), " >\n"),
                  d.push(
                    "<g ",
                    this.getSvgTransform(!1),
                    f ? "" : c + this.getSvgCommons(),
                    " >\n"
                  ),
                  (i = [
                    h,
                    u,
                    s ? "" : this.addPaintOrder(),
                    " ",
                    p ? 'transform="' + p + '" ' : "",
                  ].join("")),
                  (t[g] = i),
                  this.fill && this.fill.toLive && d.push(this.fill.toSVG(this, !1)),
                  this.stroke && this.stroke.toLive && d.push(this.stroke.toSVG(this, !1)),
                  this.shadow && d.push(this.shadow.toSVG(this)),
                  l && d.push(r),
                  d.push(t.join("")),
                  d.push("</g>\n"),
                  f && d.push("</g>\n"),
                  a ? a(d.join("")) : d.join("")
                );
              },
              addPaintOrder: function () {
                return "fill" !== this.paintFirst ? ' paint-order="' + this.paintFirst + '" ' : "";
              },
            });
          })(),
          (function () {
            var t = n.util.object.extend,
              e = "stateProperties";
            function i(e, i, n) {
              var r = {},
                s = !0;
              n.forEach(function (t) {
                r[t] = e[t];
              }),
                t(e[i], r, s);
            }
            function r(t, e, i) {
              if (t === e) return !0;
              if (Array.isArray(t)) {
                if (!Array.isArray(e) || t.length !== e.length) return !1;
                for (var n = 0, s = t.length; n < s; n++) if (!r(t[n], e[n])) return !1;
                return !0;
              }
              if (t && "object" === typeof t) {
                var o,
                  a = Object.keys(t);
                if (!e || "object" !== typeof e || (!i && a.length !== Object.keys(e).length))
                  return !1;
                for (n = 0, s = a.length; n < s; n++)
                  if (((o = a[n]), "canvas" !== o && !r(t[o], e[o]))) return !1;
                return !0;
              }
            }
            n.util.object.extend(n.Object.prototype, {
              hasStateChanged: function (t) {
                t = t || e;
                var i = "_" + t;
                return Object.keys(this[i]).length < this[t].length || !r(this[i], this, !0);
              },
              saveState: function (t) {
                var n = (t && t.propertySet) || e,
                  r = "_" + n;
                return this[r]
                  ? (i(this, r, this[n]),
                    t && t.stateProperties && i(this, r, t.stateProperties),
                    this)
                  : this.setupState(t);
              },
              setupState: function (t) {
                t = t || {};
                var i = t.propertySet || e;
                return (t.propertySet = i), (this["_" + i] = {}), this.saveState(t), this;
              },
            });
          })(),
          (function () {
            var t = n.util.degreesToRadians;
            n.util.object.extend(n.Object.prototype, {
              _controlsVisibility: null,
              _findTargetCorner: function (t) {
                if (
                  !this.hasControls ||
                  this.group ||
                  !this.canvas ||
                  this.canvas._activeObject !== this
                )
                  return !1;
                var e,
                  i,
                  n = t.x,
                  r = t.y;
                for (var s in ((this.__corner = 0), this.oCoords))
                  if (
                    this.isControlVisible(s) &&
                    ("mtr" !== s || this.hasRotatingPoint) &&
                    (!this.get("lockUniScaling") ||
                      ("mt" !== s && "mr" !== s && "mb" !== s && "ml" !== s)) &&
                    ((i = this._getImageLines(this.oCoords[s].corner)),
                    (e = this._findCrossPoints({ x: n, y: r }, i)),
                    0 !== e && e % 2 === 1)
                  )
                    return (this.__corner = s), s;
                return !1;
              },
              _setCornerCoords: function () {
                var e,
                  i,
                  r = this.oCoords,
                  s = t(45 - this.angle),
                  o = 0.707106 * this.cornerSize,
                  a = o * n.util.cos(s),
                  h = o * n.util.sin(s);
                for (var c in r)
                  (e = r[c].x),
                    (i = r[c].y),
                    (r[c].corner = {
                      tl: { x: e - h, y: i - a },
                      tr: { x: e + a, y: i - h },
                      bl: { x: e - a, y: i + h },
                      br: { x: e + h, y: i + a },
                    });
              },
              drawSelectionBackground: function (e) {
                if (
                  !this.selectionBackgroundColor ||
                  (this.canvas && !this.canvas.interactive) ||
                  (this.canvas && this.canvas._activeObject !== this)
                )
                  return this;
                e.save();
                var i = this.getCenterPoint(),
                  n = this._calculateCurrentDimensions(),
                  r = this.canvas.viewportTransform;
                return (
                  e.translate(i.x, i.y),
                  e.scale(1 / r[0], 1 / r[3]),
                  e.rotate(t(this.angle)),
                  (e.fillStyle = this.selectionBackgroundColor),
                  e.fillRect(-n.x / 2, -n.y / 2, n.x, n.y),
                  e.restore(),
                  this
                );
              },
              drawBorders: function (t, e) {
                e = e || {};
                var i = this._calculateCurrentDimensions(),
                  n = 1 / this.borderScaleFactor,
                  r = i.x + n,
                  s = i.y + n,
                  o =
                    "undefined" !== typeof e.hasRotatingPoint
                      ? e.hasRotatingPoint
                      : this.hasRotatingPoint,
                  a = "undefined" !== typeof e.hasControls ? e.hasControls : this.hasControls,
                  h =
                    "undefined" !== typeof e.rotatingPointOffset
                      ? e.rotatingPointOffset
                      : this.rotatingPointOffset;
                if (
                  (t.save(),
                  (t.strokeStyle = e.borderColor || this.borderColor),
                  this._setLineDash(t, e.borderDashArray || this.borderDashArray, null),
                  t.strokeRect(-r / 2, -s / 2, r, s),
                  o && this.isControlVisible("mtr") && a)
                ) {
                  var c = -s / 2;
                  t.beginPath(), t.moveTo(0, c), t.lineTo(0, c - h), t.stroke();
                }
                return t.restore(), this;
              },
              drawBordersInGroup: function (t, e, i) {
                i = i || {};
                var r = this._getNonTransformedDimensions(),
                  s = n.util.customTransformMatrix(e.scaleX, e.scaleY, e.skewX),
                  o = n.util.transformPoint(r, s),
                  a = 1 / this.borderScaleFactor,
                  h = o.x + a,
                  c = o.y + a;
                return (
                  t.save(),
                  this._setLineDash(t, i.borderDashArray || this.borderDashArray, null),
                  (t.strokeStyle = i.borderColor || this.borderColor),
                  t.strokeRect(-h / 2, -c / 2, h, c),
                  t.restore(),
                  this
                );
              },
              drawControls: function (t, e) {
                e = e || {};
                var i = this._calculateCurrentDimensions(),
                  n = i.x,
                  r = i.y,
                  s = e.cornerSize || this.cornerSize,
                  o = -(n + s) / 2,
                  a = -(r + s) / 2,
                  h =
                    "undefined" !== typeof e.transparentCorners
                      ? e.transparentCorners
                      : this.transparentCorners,
                  c =
                    "undefined" !== typeof e.hasRotatingPoint
                      ? e.hasRotatingPoint
                      : this.hasRotatingPoint,
                  l = h ? "stroke" : "fill";
                return (
                  t.save(),
                  (t.strokeStyle = t.fillStyle = e.cornerColor || this.cornerColor),
                  this.transparentCorners ||
                    (t.strokeStyle = e.cornerStrokeColor || this.cornerStrokeColor),
                  this._setLineDash(t, e.cornerDashArray || this.cornerDashArray, null),
                  this._drawControl("tl", t, l, o, a, e),
                  this._drawControl("tr", t, l, o + n, a, e),
                  this._drawControl("bl", t, l, o, a + r, e),
                  this._drawControl("br", t, l, o + n, a + r, e),
                  this.get("lockUniScaling") ||
                    (this._drawControl("mt", t, l, o + n / 2, a, e),
                    this._drawControl("mb", t, l, o + n / 2, a + r, e),
                    this._drawControl("mr", t, l, o + n, a + r / 2, e),
                    this._drawControl("ml", t, l, o, a + r / 2, e)),
                  c && this._drawControl("mtr", t, l, o + n / 2, a - this.rotatingPointOffset, e),
                  t.restore(),
                  this
                );
              },
              _drawControl: function (t, e, i, n, r, s) {
                if (((s = s || {}), this.isControlVisible(t))) {
                  var o = this.cornerSize,
                    a = !this.transparentCorners && this.cornerStrokeColor;
                  switch (s.cornerStyle || this.cornerStyle) {
                    case "circle":
                      e.beginPath(),
                        e.arc(n + o / 2, r + o / 2, o / 2, 0, 2 * Math.PI, !1),
                        e[i](),
                        a && e.stroke();
                      break;
                    default:
                      this.transparentCorners || e.clearRect(n, r, o, o),
                        e[i + "Rect"](n, r, o, o),
                        a && e.strokeRect(n, r, o, o);
                  }
                }
              },
              isControlVisible: function (t) {
                return this._getControlsVisibility()[t];
              },
              setControlVisible: function (t, e) {
                return (this._getControlsVisibility()[t] = e), this;
              },
              setControlsVisibility: function (t) {
                for (var e in (t || (t = {}), t)) this.setControlVisible(e, t[e]);
                return this;
              },
              _getControlsVisibility: function () {
                return (
                  this._controlsVisibility ||
                    (this._controlsVisibility = {
                      tl: !0,
                      tr: !0,
                      br: !0,
                      bl: !0,
                      ml: !0,
                      mt: !0,
                      mr: !0,
                      mb: !0,
                      mtr: !0,
                    }),
                  this._controlsVisibility
                );
              },
              onDeselect: function () {},
              onSelect: function () {},
            });
          })(),
          n.util.object.extend(n.StaticCanvas.prototype, {
            FX_DURATION: 500,
            fxCenterObjectH: function (t, e) {
              e = e || {};
              var i = function () {},
                r = e.onComplete || i,
                s = e.onChange || i,
                o = this;
              return (
                n.util.animate({
                  startValue: t.left,
                  endValue: this.getCenter().left,
                  duration: this.FX_DURATION,
                  onChange: function (e) {
                    t.set("left", e), o.requestRenderAll(), s();
                  },
                  onComplete: function () {
                    t.setCoords(), r();
                  },
                }),
                this
              );
            },
            fxCenterObjectV: function (t, e) {
              e = e || {};
              var i = function () {},
                r = e.onComplete || i,
                s = e.onChange || i,
                o = this;
              return (
                n.util.animate({
                  startValue: t.top,
                  endValue: this.getCenter().top,
                  duration: this.FX_DURATION,
                  onChange: function (e) {
                    t.set("top", e), o.requestRenderAll(), s();
                  },
                  onComplete: function () {
                    t.setCoords(), r();
                  },
                }),
                this
              );
            },
            fxRemove: function (t, e) {
              e = e || {};
              var i = function () {},
                r = e.onComplete || i,
                s = e.onChange || i,
                o = this;
              return (
                n.util.animate({
                  startValue: t.opacity,
                  endValue: 0,
                  duration: this.FX_DURATION,
                  onChange: function (e) {
                    t.set("opacity", e), o.requestRenderAll(), s();
                  },
                  onComplete: function () {
                    o.remove(t), r();
                  },
                }),
                this
              );
            },
          }),
          n.util.object.extend(n.Object.prototype, {
            animate: function () {
              if (arguments[0] && "object" === typeof arguments[0]) {
                var t,
                  e,
                  i = [];
                for (t in arguments[0]) i.push(t);
                for (var n = 0, r = i.length; n < r; n++)
                  (t = i[n]), (e = n !== r - 1), this._animate(t, arguments[0][t], arguments[1], e);
              } else this._animate.apply(this, arguments);
              return this;
            },
            _animate: function (t, e, i, r) {
              var s,
                o = this;
              (e = e.toString()),
                (i = i ? n.util.object.clone(i) : {}),
                ~t.indexOf(".") && (s = t.split("."));
              var a = s ? this.get(s[0])[s[1]] : this.get(t);
              "from" in i || (i.from = a),
                (e = ~e.indexOf("=") ? a + parseFloat(e.replace("=", "")) : parseFloat(e)),
                n.util.animate({
                  startValue: i.from,
                  endValue: e,
                  byValue: i.by,
                  easing: i.easing,
                  duration: i.duration,
                  abort:
                    i.abort &&
                    function () {
                      return i.abort.call(o);
                    },
                  onChange: function (e, n, a) {
                    s ? (o[s[0]][s[1]] = e) : o.set(t, e), r || (i.onChange && i.onChange(e, n, a));
                  },
                  onComplete: function (t, e, n) {
                    r || (o.setCoords(), i.onComplete && i.onComplete(t, e, n));
                  },
                });
            },
          }),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend,
              n = e.util.object.clone,
              r = { x1: 1, x2: 1, y1: 1, y2: 1 },
              s = e.StaticCanvas.supports("setLineDash");
            function o(t, e) {
              var i = t.origin,
                n = t.axis1,
                r = t.axis2,
                s = t.dimension,
                o = e.nearest,
                a = e.center,
                h = e.farthest;
              return function () {
                switch (this.get(i)) {
                  case o:
                    return Math.min(this.get(n), this.get(r));
                  case a:
                    return Math.min(this.get(n), this.get(r)) + 0.5 * this.get(s);
                  case h:
                    return Math.max(this.get(n), this.get(r));
                }
              };
            }
            e.Line
              ? e.warn("fabric.Line is already defined")
              : ((e.Line = e.util.createClass(e.Object, {
                  type: "line",
                  x1: 0,
                  y1: 0,
                  x2: 0,
                  y2: 0,
                  cacheProperties: e.Object.prototype.cacheProperties.concat(
                    "x1",
                    "x2",
                    "y1",
                    "y2"
                  ),
                  initialize: function (t, e) {
                    t || (t = [0, 0, 0, 0]),
                      this.callSuper("initialize", e),
                      this.set("x1", t[0]),
                      this.set("y1", t[1]),
                      this.set("x2", t[2]),
                      this.set("y2", t[3]),
                      this._setWidthHeight(e);
                  },
                  _setWidthHeight: function (t) {
                    t || (t = {}),
                      (this.width = Math.abs(this.x2 - this.x1)),
                      (this.height = Math.abs(this.y2 - this.y1)),
                      (this.left = "left" in t ? t.left : this._getLeftToOriginX()),
                      (this.top = "top" in t ? t.top : this._getTopToOriginY());
                  },
                  _set: function (t, e) {
                    return (
                      this.callSuper("_set", t, e),
                      "undefined" !== typeof r[t] && this._setWidthHeight(),
                      this
                    );
                  },
                  _getLeftToOriginX: o(
                    { origin: "originX", axis1: "x1", axis2: "x2", dimension: "width" },
                    { nearest: "left", center: "center", farthest: "right" }
                  ),
                  _getTopToOriginY: o(
                    { origin: "originY", axis1: "y1", axis2: "y2", dimension: "height" },
                    { nearest: "top", center: "center", farthest: "bottom" }
                  ),
                  _render: function (t) {
                    if ((t.beginPath(), !this.strokeDashArray || (this.strokeDashArray && s))) {
                      var e = this.calcLinePoints();
                      t.moveTo(e.x1, e.y1), t.lineTo(e.x2, e.y2);
                    }
                    t.lineWidth = this.strokeWidth;
                    var i = t.strokeStyle;
                    (t.strokeStyle = this.stroke || t.fillStyle),
                      this.stroke && this._renderStroke(t),
                      (t.strokeStyle = i);
                  },
                  _renderDashedStroke: function (t) {
                    var i = this.calcLinePoints();
                    t.beginPath(),
                      e.util.drawDashedLine(t, i.x1, i.y1, i.x2, i.y2, this.strokeDashArray),
                      t.closePath();
                  },
                  _findCenterFromElement: function () {
                    return { x: (this.x1 + this.x2) / 2, y: (this.y1 + this.y2) / 2 };
                  },
                  toObject: function (t) {
                    return i(this.callSuper("toObject", t), this.calcLinePoints());
                  },
                  _getNonTransformedDimensions: function () {
                    var t = this.callSuper("_getNonTransformedDimensions");
                    return (
                      "butt" === this.strokeLineCap &&
                        (0 === this.width && (t.y -= this.strokeWidth),
                        0 === this.height && (t.x -= this.strokeWidth)),
                      t
                    );
                  },
                  calcLinePoints: function () {
                    var t = this.x1 <= this.x2 ? -1 : 1,
                      e = this.y1 <= this.y2 ? -1 : 1,
                      i = t * this.width * 0.5,
                      n = e * this.height * 0.5,
                      r = t * this.width * -0.5,
                      s = e * this.height * -0.5;
                    return { x1: i, x2: r, y1: n, y2: s };
                  },
                  _toSVG: function () {
                    var t = this.calcLinePoints();
                    return [
                      "<line ",
                      "COMMON_PARTS",
                      'x1="',
                      t.x1,
                      '" y1="',
                      t.y1,
                      '" x2="',
                      t.x2,
                      '" y2="',
                      t.y2,
                      '" />\n',
                    ];
                  },
                })),
                (e.Line.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" "))),
                (e.Line.fromElement = function (t, n, r) {
                  r = r || {};
                  var s = e.parseAttributes(t, e.Line.ATTRIBUTE_NAMES),
                    o = [s.x1 || 0, s.y1 || 0, s.x2 || 0, s.y2 || 0];
                  n(new e.Line(o, i(s, r)));
                }),
                (e.Line.fromObject = function (t, i) {
                  function r(t) {
                    delete t.points, i && i(t);
                  }
                  var s = n(t, !0);
                  (s.points = [t.x1, t.y1, t.x2, t.y2]),
                    e.Object._fromObject("Line", s, r, "points");
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = Math.PI;
            function n(t) {
              return "radius" in t && t.radius >= 0;
            }
            e.Circle
              ? e.warn("fabric.Circle is already defined.")
              : ((e.Circle = e.util.createClass(e.Object, {
                  type: "circle",
                  radius: 0,
                  startAngle: 0,
                  endAngle: 2 * i,
                  cacheProperties: e.Object.prototype.cacheProperties.concat(
                    "radius",
                    "startAngle",
                    "endAngle"
                  ),
                  _set: function (t, e) {
                    return this.callSuper("_set", t, e), "radius" === t && this.setRadius(e), this;
                  },
                  toObject: function (t) {
                    return this.callSuper(
                      "toObject",
                      ["radius", "startAngle", "endAngle"].concat(t)
                    );
                  },
                  _toSVG: function () {
                    var t,
                      n = 0,
                      r = 0,
                      s = (this.endAngle - this.startAngle) % (2 * i);
                    if (0 === s)
                      t = [
                        "<circle ",
                        "COMMON_PARTS",
                        'cx="' + n + '" cy="' + r + '" ',
                        'r="',
                        this.radius,
                        '" />\n',
                      ];
                    else {
                      var o = e.util.cos(this.startAngle) * this.radius,
                        a = e.util.sin(this.startAngle) * this.radius,
                        h = e.util.cos(this.endAngle) * this.radius,
                        c = e.util.sin(this.endAngle) * this.radius,
                        l = s > i ? "1" : "0";
                      t = [
                        '<path d="M ' + o + " " + a,
                        " A " + this.radius + " " + this.radius,
                        " 0 ",
                        +l + " 1",
                        " " + h + " " + c,
                        '" ',
                        "COMMON_PARTS",
                        " />\n",
                      ];
                    }
                    return t;
                  },
                  _render: function (t) {
                    t.beginPath(),
                      t.arc(0, 0, this.radius, this.startAngle, this.endAngle, !1),
                      this._renderPaintInOrder(t);
                  },
                  getRadiusX: function () {
                    return this.get("radius") * this.get("scaleX");
                  },
                  getRadiusY: function () {
                    return this.get("radius") * this.get("scaleY");
                  },
                  setRadius: function (t) {
                    return (this.radius = t), this.set("width", 2 * t).set("height", 2 * t);
                  },
                })),
                (e.Circle.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat("cx cy r".split(" "))),
                (e.Circle.fromElement = function (t, i) {
                  var r = e.parseAttributes(t, e.Circle.ATTRIBUTE_NAMES);
                  if (!n(r))
                    throw new Error("value of `r` attribute is required and can not be negative");
                  (r.left = (r.left || 0) - r.radius),
                    (r.top = (r.top || 0) - r.radius),
                    i(new e.Circle(r));
                }),
                (e.Circle.fromObject = function (t, i) {
                  return e.Object._fromObject("Circle", t, i);
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {});
            e.Triangle
              ? e.warn("fabric.Triangle is already defined")
              : ((e.Triangle = e.util.createClass(e.Object, {
                  type: "triangle",
                  width: 100,
                  height: 100,
                  _render: function (t) {
                    var e = this.width / 2,
                      i = this.height / 2;
                    t.beginPath(),
                      t.moveTo(-e, i),
                      t.lineTo(0, -i),
                      t.lineTo(e, i),
                      t.closePath(),
                      this._renderPaintInOrder(t);
                  },
                  _renderDashedStroke: function (t) {
                    var i = this.width / 2,
                      n = this.height / 2;
                    t.beginPath(),
                      e.util.drawDashedLine(t, -i, n, 0, -n, this.strokeDashArray),
                      e.util.drawDashedLine(t, 0, -n, i, n, this.strokeDashArray),
                      e.util.drawDashedLine(t, i, n, -i, n, this.strokeDashArray),
                      t.closePath();
                  },
                  _toSVG: function () {
                    var t = this.width / 2,
                      e = this.height / 2,
                      i = [-t + " " + e, "0 " + -e, t + " " + e].join(",");
                    return ["<polygon ", "COMMON_PARTS", 'points="', i, '" />'];
                  },
                })),
                (e.Triangle.fromObject = function (t, i) {
                  return e.Object._fromObject("Triangle", t, i);
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = 2 * Math.PI;
            e.Ellipse
              ? e.warn("fabric.Ellipse is already defined.")
              : ((e.Ellipse = e.util.createClass(e.Object, {
                  type: "ellipse",
                  rx: 0,
                  ry: 0,
                  cacheProperties: e.Object.prototype.cacheProperties.concat("rx", "ry"),
                  initialize: function (t) {
                    this.callSuper("initialize", t),
                      this.set("rx", (t && t.rx) || 0),
                      this.set("ry", (t && t.ry) || 0);
                  },
                  _set: function (t, e) {
                    switch ((this.callSuper("_set", t, e), t)) {
                      case "rx":
                        (this.rx = e), this.set("width", 2 * e);
                        break;
                      case "ry":
                        (this.ry = e), this.set("height", 2 * e);
                        break;
                    }
                    return this;
                  },
                  getRx: function () {
                    return this.get("rx") * this.get("scaleX");
                  },
                  getRy: function () {
                    return this.get("ry") * this.get("scaleY");
                  },
                  toObject: function (t) {
                    return this.callSuper("toObject", ["rx", "ry"].concat(t));
                  },
                  _toSVG: function () {
                    return [
                      "<ellipse ",
                      "COMMON_PARTS",
                      'cx="0" cy="0" ',
                      'rx="',
                      this.rx,
                      '" ry="',
                      this.ry,
                      '" />\n',
                    ];
                  },
                  _render: function (t) {
                    t.beginPath(),
                      t.save(),
                      t.transform(1, 0, 0, this.ry / this.rx, 0, 0),
                      t.arc(0, 0, this.rx, 0, i, !1),
                      t.restore(),
                      this._renderPaintInOrder(t);
                  },
                })),
                (e.Ellipse.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" "))),
                (e.Ellipse.fromElement = function (t, i) {
                  var n = e.parseAttributes(t, e.Ellipse.ATTRIBUTE_NAMES);
                  (n.left = (n.left || 0) - n.rx),
                    (n.top = (n.top || 0) - n.ry),
                    i(new e.Ellipse(n));
                }),
                (e.Ellipse.fromObject = function (t, i) {
                  return e.Object._fromObject("Ellipse", t, i);
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend;
            e.Rect
              ? e.warn("fabric.Rect is already defined")
              : ((e.Rect = e.util.createClass(e.Object, {
                  stateProperties: e.Object.prototype.stateProperties.concat("rx", "ry"),
                  type: "rect",
                  rx: 0,
                  ry: 0,
                  cacheProperties: e.Object.prototype.cacheProperties.concat("rx", "ry"),
                  initialize: function (t) {
                    this.callSuper("initialize", t), this._initRxRy();
                  },
                  _initRxRy: function () {
                    this.rx && !this.ry
                      ? (this.ry = this.rx)
                      : this.ry && !this.rx && (this.rx = this.ry);
                  },
                  _render: function (t) {
                    var e = this.rx ? Math.min(this.rx, this.width / 2) : 0,
                      i = this.ry ? Math.min(this.ry, this.height / 2) : 0,
                      n = this.width,
                      r = this.height,
                      s = -this.width / 2,
                      o = -this.height / 2,
                      a = 0 !== e || 0 !== i,
                      h = 0.4477152502;
                    t.beginPath(),
                      t.moveTo(s + e, o),
                      t.lineTo(s + n - e, o),
                      a && t.bezierCurveTo(s + n - h * e, o, s + n, o + h * i, s + n, o + i),
                      t.lineTo(s + n, o + r - i),
                      a &&
                        t.bezierCurveTo(
                          s + n,
                          o + r - h * i,
                          s + n - h * e,
                          o + r,
                          s + n - e,
                          o + r
                        ),
                      t.lineTo(s + e, o + r),
                      a && t.bezierCurveTo(s + h * e, o + r, s, o + r - h * i, s, o + r - i),
                      t.lineTo(s, o + i),
                      a && t.bezierCurveTo(s, o + h * i, s + h * e, o, s + e, o),
                      t.closePath(),
                      this._renderPaintInOrder(t);
                  },
                  _renderDashedStroke: function (t) {
                    var i = -this.width / 2,
                      n = -this.height / 2,
                      r = this.width,
                      s = this.height;
                    t.beginPath(),
                      e.util.drawDashedLine(t, i, n, i + r, n, this.strokeDashArray),
                      e.util.drawDashedLine(t, i + r, n, i + r, n + s, this.strokeDashArray),
                      e.util.drawDashedLine(t, i + r, n + s, i, n + s, this.strokeDashArray),
                      e.util.drawDashedLine(t, i, n + s, i, n, this.strokeDashArray),
                      t.closePath();
                  },
                  toObject: function (t) {
                    return this.callSuper("toObject", ["rx", "ry"].concat(t));
                  },
                  _toSVG: function () {
                    var t = -this.width / 2,
                      e = -this.height / 2;
                    return [
                      "<rect ",
                      "COMMON_PARTS",
                      'x="',
                      t,
                      '" y="',
                      e,
                      '" rx="',
                      this.rx,
                      '" ry="',
                      this.ry,
                      '" width="',
                      this.width,
                      '" height="',
                      this.height,
                      '" />\n',
                    ];
                  },
                })),
                (e.Rect.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat(
                  "x y rx ry width height".split(" ")
                )),
                (e.Rect.fromElement = function (t, n, r) {
                  if (!t) return n(null);
                  r = r || {};
                  var s = e.parseAttributes(t, e.Rect.ATTRIBUTE_NAMES);
                  (s.left = s.left || 0), (s.top = s.top || 0);
                  var o = new e.Rect(i(r ? e.util.object.clone(r) : {}, s));
                  (o.visible = o.visible && o.width > 0 && o.height > 0), n(o);
                }),
                (e.Rect.fromObject = function (t, i) {
                  return e.Object._fromObject("Rect", t, i);
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend,
              n = e.util.array.min,
              r = e.util.array.max,
              s = e.util.toFixed;
            e.Polyline
              ? e.warn("fabric.Polyline is already defined")
              : ((e.Polyline = e.util.createClass(e.Object, {
                  type: "polyline",
                  points: null,
                  cacheProperties: e.Object.prototype.cacheProperties.concat("points"),
                  initialize: function (t, e) {
                    (e = e || {}), (this.points = t || []), this.callSuper("initialize", e);
                    var i = this._calcDimensions();
                    "undefined" === typeof e.left && (this.left = i.left),
                      "undefined" === typeof e.top && (this.top = i.top),
                      (this.width = i.width),
                      (this.height = i.height),
                      (this.pathOffset = {
                        x: i.left + this.width / 2,
                        y: i.top + this.height / 2,
                      });
                  },
                  _calcDimensions: function () {
                    var t = this.points,
                      e = n(t, "x") || 0,
                      i = n(t, "y") || 0,
                      s = r(t, "x") || 0,
                      o = r(t, "y") || 0,
                      a = s - e,
                      h = o - i;
                    return { left: e, top: i, width: a, height: h };
                  },
                  toObject: function (t) {
                    return i(this.callSuper("toObject", t), { points: this.points.concat() });
                  },
                  _toSVG: function () {
                    for (
                      var t = [],
                        i = this.pathOffset.x,
                        n = this.pathOffset.y,
                        r = e.Object.NUM_FRACTION_DIGITS,
                        o = 0,
                        a = this.points.length;
                      o < a;
                      o++
                    )
                      t.push(s(this.points[o].x - i, r), ",", s(this.points[o].y - n, r), " ");
                    return [
                      "<" + this.type + " ",
                      "COMMON_PARTS",
                      'points="',
                      t.join(""),
                      '" />\n',
                    ];
                  },
                  commonRender: function (t) {
                    var e,
                      i = this.points.length,
                      n = this.pathOffset.x,
                      r = this.pathOffset.y;
                    if (!i || isNaN(this.points[i - 1].y)) return !1;
                    t.beginPath(), t.moveTo(this.points[0].x - n, this.points[0].y - r);
                    for (var s = 0; s < i; s++) (e = this.points[s]), t.lineTo(e.x - n, e.y - r);
                    return !0;
                  },
                  _render: function (t) {
                    this.commonRender(t) && this._renderPaintInOrder(t);
                  },
                  _renderDashedStroke: function (t) {
                    var i, n;
                    t.beginPath();
                    for (var r = 0, s = this.points.length; r < s; r++)
                      (i = this.points[r]),
                        (n = this.points[r + 1] || i),
                        e.util.drawDashedLine(t, i.x, i.y, n.x, n.y, this.strokeDashArray);
                  },
                  complexity: function () {
                    return this.get("points").length;
                  },
                })),
                (e.Polyline.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat()),
                (e.Polyline.fromElement = function (t, i, n) {
                  if (!t) return i(null);
                  n || (n = {});
                  var r = e.parsePointsAttribute(t.getAttribute("points")),
                    s = e.parseAttributes(t, e.Polyline.ATTRIBUTE_NAMES);
                  i(new e.Polyline(r, e.util.object.extend(s, n)));
                }),
                (e.Polyline.fromObject = function (t, i) {
                  return e.Object._fromObject("Polyline", t, i, "points");
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend;
            e.Polygon
              ? e.warn("fabric.Polygon is already defined")
              : ((e.Polygon = e.util.createClass(e.Polyline, {
                  type: "polygon",
                  _render: function (t) {
                    this.commonRender(t) && (t.closePath(), this._renderPaintInOrder(t));
                  },
                  _renderDashedStroke: function (t) {
                    this.callSuper("_renderDashedStroke", t), t.closePath();
                  },
                })),
                (e.Polygon.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat()),
                (e.Polygon.fromElement = function (t, n, r) {
                  if (!t) return n(null);
                  r || (r = {});
                  var s = e.parsePointsAttribute(t.getAttribute("points")),
                    o = e.parseAttributes(t, e.Polygon.ATTRIBUTE_NAMES);
                  n(new e.Polygon(s, i(o, r)));
                }),
                (e.Polygon.fromObject = function (t, i) {
                  return e.Object._fromObject("Polygon", t, i, "points");
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.array.min,
              n = e.util.array.max,
              r = e.util.object.extend,
              s = Object.prototype.toString,
              o = e.util.drawArc,
              a = e.util.toFixed,
              h = { m: 2, l: 2, h: 1, v: 1, c: 6, s: 4, q: 4, t: 2, a: 7 },
              c = { m: "l", M: "L" };
            e.Path
              ? e.warn("fabric.Path is already defined")
              : ((e.Path = e.util.createClass(e.Object, {
                  type: "path",
                  path: null,
                  cacheProperties: e.Object.prototype.cacheProperties.concat("path", "fillRule"),
                  stateProperties: e.Object.prototype.stateProperties.concat("path"),
                  initialize: function (t, e) {
                    (e = e || {}), this.callSuper("initialize", e), t || (t = []);
                    var i = "[object Array]" === s.call(t);
                    (this.path = i ? t : t.match && t.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi)),
                      this.path &&
                        (i || (this.path = this._parsePath()), this._setPositionDimensions(e));
                  },
                  _setPositionDimensions: function (t) {
                    var e = this._parseDimensions();
                    (this.width = e.width),
                      (this.height = e.height),
                      "undefined" === typeof t.left && (this.left = e.left),
                      "undefined" === typeof t.top && (this.top = e.top),
                      (this.pathOffset = this.pathOffset || {
                        x: e.left + this.width / 2,
                        y: e.top + this.height / 2,
                      });
                  },
                  _renderPathCommands: function (t) {
                    var e,
                      i,
                      n,
                      r = null,
                      s = 0,
                      a = 0,
                      h = 0,
                      c = 0,
                      l = 0,
                      u = 0,
                      f = -this.pathOffset.x,
                      d = -this.pathOffset.y;
                    t.beginPath();
                    for (var g = 0, p = this.path.length; g < p; ++g) {
                      switch (((e = this.path[g]), e[0])) {
                        case "l":
                          (h += e[1]), (c += e[2]), t.lineTo(h + f, c + d);
                          break;
                        case "L":
                          (h = e[1]), (c = e[2]), t.lineTo(h + f, c + d);
                          break;
                        case "h":
                          (h += e[1]), t.lineTo(h + f, c + d);
                          break;
                        case "H":
                          (h = e[1]), t.lineTo(h + f, c + d);
                          break;
                        case "v":
                          (c += e[1]), t.lineTo(h + f, c + d);
                          break;
                        case "V":
                          (c = e[1]), t.lineTo(h + f, c + d);
                          break;
                        case "m":
                          (h += e[1]), (c += e[2]), (s = h), (a = c), t.moveTo(h + f, c + d);
                          break;
                        case "M":
                          (h = e[1]), (c = e[2]), (s = h), (a = c), t.moveTo(h + f, c + d);
                          break;
                        case "c":
                          (i = h + e[5]),
                            (n = c + e[6]),
                            (l = h + e[3]),
                            (u = c + e[4]),
                            t.bezierCurveTo(h + e[1] + f, c + e[2] + d, l + f, u + d, i + f, n + d),
                            (h = i),
                            (c = n);
                          break;
                        case "C":
                          (h = e[5]),
                            (c = e[6]),
                            (l = e[3]),
                            (u = e[4]),
                            t.bezierCurveTo(e[1] + f, e[2] + d, l + f, u + d, h + f, c + d);
                          break;
                        case "s":
                          (i = h + e[3]),
                            (n = c + e[4]),
                            null === r[0].match(/[CcSs]/)
                              ? ((l = h), (u = c))
                              : ((l = 2 * h - l), (u = 2 * c - u)),
                            t.bezierCurveTo(l + f, u + d, h + e[1] + f, c + e[2] + d, i + f, n + d),
                            (l = h + e[1]),
                            (u = c + e[2]),
                            (h = i),
                            (c = n);
                          break;
                        case "S":
                          (i = e[3]),
                            (n = e[4]),
                            null === r[0].match(/[CcSs]/)
                              ? ((l = h), (u = c))
                              : ((l = 2 * h - l), (u = 2 * c - u)),
                            t.bezierCurveTo(l + f, u + d, e[1] + f, e[2] + d, i + f, n + d),
                            (h = i),
                            (c = n),
                            (l = e[1]),
                            (u = e[2]);
                          break;
                        case "q":
                          (i = h + e[3]),
                            (n = c + e[4]),
                            (l = h + e[1]),
                            (u = c + e[2]),
                            t.quadraticCurveTo(l + f, u + d, i + f, n + d),
                            (h = i),
                            (c = n);
                          break;
                        case "Q":
                          (i = e[3]),
                            (n = e[4]),
                            t.quadraticCurveTo(e[1] + f, e[2] + d, i + f, n + d),
                            (h = i),
                            (c = n),
                            (l = e[1]),
                            (u = e[2]);
                          break;
                        case "t":
                          (i = h + e[1]),
                            (n = c + e[2]),
                            null === r[0].match(/[QqTt]/)
                              ? ((l = h), (u = c))
                              : ((l = 2 * h - l), (u = 2 * c - u)),
                            t.quadraticCurveTo(l + f, u + d, i + f, n + d),
                            (h = i),
                            (c = n);
                          break;
                        case "T":
                          (i = e[1]),
                            (n = e[2]),
                            null === r[0].match(/[QqTt]/)
                              ? ((l = h), (u = c))
                              : ((l = 2 * h - l), (u = 2 * c - u)),
                            t.quadraticCurveTo(l + f, u + d, i + f, n + d),
                            (h = i),
                            (c = n);
                          break;
                        case "a":
                          o(t, h + f, c + d, [
                            e[1],
                            e[2],
                            e[3],
                            e[4],
                            e[5],
                            e[6] + h + f,
                            e[7] + c + d,
                          ]),
                            (h += e[6]),
                            (c += e[7]);
                          break;
                        case "A":
                          o(t, h + f, c + d, [e[1], e[2], e[3], e[4], e[5], e[6] + f, e[7] + d]),
                            (h = e[6]),
                            (c = e[7]);
                          break;
                        case "z":
                        case "Z":
                          (h = s), (c = a), t.closePath();
                          break;
                      }
                      r = e;
                    }
                  },
                  _render: function (t) {
                    this._renderPathCommands(t), this._renderPaintInOrder(t);
                  },
                  toString: function () {
                    return (
                      "#<fabric.Path (" +
                      this.complexity() +
                      '): { "top": ' +
                      this.top +
                      ', "left": ' +
                      this.left +
                      " }>"
                    );
                  },
                  toObject: function (t) {
                    var e = r(this.callSuper("toObject", t), {
                      path: this.path.map(function (t) {
                        return t.slice();
                      }),
                      top: this.top,
                      left: this.left,
                    });
                    return e;
                  },
                  toDatalessObject: function (t) {
                    var e = this.toObject(["sourcePath"].concat(t));
                    return e.sourcePath && delete e.path, e;
                  },
                  _toSVG: function () {
                    var t = this.path
                      .map(function (t) {
                        return t.join(" ");
                      })
                      .join(" ");
                    return [
                      "<path ",
                      "COMMON_PARTS",
                      'd="',
                      t,
                      '" stroke-linecap="round" ',
                      "/>\n",
                    ];
                  },
                  _getOffsetTransform: function () {
                    var t = e.Object.NUM_FRACTION_DIGITS;
                    return (
                      " translate(" +
                      a(-this.pathOffset.x, t) +
                      ", " +
                      a(-this.pathOffset.y, t) +
                      ")"
                    );
                  },
                  toClipPathSVG: function (t) {
                    var e = this._getOffsetTransform();
                    return (
                      "\t" +
                      this._createBaseClipPathSVGMarkup(this._toSVG(), {
                        reviver: t,
                        additionalTransform: e,
                      })
                    );
                  },
                  toSVG: function (t) {
                    var e = this._getOffsetTransform();
                    return this._createBaseSVGMarkup(this._toSVG(), {
                      reviver: t,
                      additionalTransform: e,
                    });
                  },
                  complexity: function () {
                    return this.path.length;
                  },
                  _parsePath: function () {
                    for (
                      var t,
                        e,
                        i,
                        n,
                        r,
                        s = [],
                        o = [],
                        a = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,
                        l = 0,
                        u = this.path.length;
                      l < u;
                      l++
                    ) {
                      (t = this.path[l]), (n = t.slice(1).trim()), (o.length = 0);
                      while ((i = a.exec(n))) o.push(i[0]);
                      r = [t.charAt(0)];
                      for (var f = 0, d = o.length; f < d; f++)
                        (e = parseFloat(o[f])), isNaN(e) || r.push(e);
                      var g = r[0],
                        p = h[g.toLowerCase()],
                        m = c[g] || g;
                      if (r.length - 1 > p)
                        for (var v = 1, _ = r.length; v < _; v += p)
                          s.push([g].concat(r.slice(v, v + p))), (g = m);
                      else s.push(r);
                    }
                    return s;
                  },
                  _parseDimensions: function () {
                    for (
                      var t,
                        r,
                        s,
                        o,
                        a = [],
                        h = [],
                        c = null,
                        l = 0,
                        u = 0,
                        f = 0,
                        d = 0,
                        g = 0,
                        p = 0,
                        m = 0,
                        v = this.path.length;
                      m < v;
                      ++m
                    ) {
                      switch (((t = this.path[m]), t[0])) {
                        case "l":
                          (f += t[1]), (d += t[2]), (o = []);
                          break;
                        case "L":
                          (f = t[1]), (d = t[2]), (o = []);
                          break;
                        case "h":
                          (f += t[1]), (o = []);
                          break;
                        case "H":
                          (f = t[1]), (o = []);
                          break;
                        case "v":
                          (d += t[1]), (o = []);
                          break;
                        case "V":
                          (d = t[1]), (o = []);
                          break;
                        case "m":
                          (f += t[1]), (d += t[2]), (l = f), (u = d), (o = []);
                          break;
                        case "M":
                          (f = t[1]), (d = t[2]), (l = f), (u = d), (o = []);
                          break;
                        case "c":
                          (r = f + t[5]),
                            (s = d + t[6]),
                            (g = f + t[3]),
                            (p = d + t[4]),
                            (o = e.util.getBoundsOfCurve(f, d, f + t[1], d + t[2], g, p, r, s)),
                            (f = r),
                            (d = s);
                          break;
                        case "C":
                          (g = t[3]),
                            (p = t[4]),
                            (o = e.util.getBoundsOfCurve(f, d, t[1], t[2], g, p, t[5], t[6])),
                            (f = t[5]),
                            (d = t[6]);
                          break;
                        case "s":
                          (r = f + t[3]),
                            (s = d + t[4]),
                            null === c[0].match(/[CcSs]/)
                              ? ((g = f), (p = d))
                              : ((g = 2 * f - g), (p = 2 * d - p)),
                            (o = e.util.getBoundsOfCurve(f, d, g, p, f + t[1], d + t[2], r, s)),
                            (g = f + t[1]),
                            (p = d + t[2]),
                            (f = r),
                            (d = s);
                          break;
                        case "S":
                          (r = t[3]),
                            (s = t[4]),
                            null === c[0].match(/[CcSs]/)
                              ? ((g = f), (p = d))
                              : ((g = 2 * f - g), (p = 2 * d - p)),
                            (o = e.util.getBoundsOfCurve(f, d, g, p, t[1], t[2], r, s)),
                            (f = r),
                            (d = s),
                            (g = t[1]),
                            (p = t[2]);
                          break;
                        case "q":
                          (r = f + t[3]),
                            (s = d + t[4]),
                            (g = f + t[1]),
                            (p = d + t[2]),
                            (o = e.util.getBoundsOfCurve(f, d, g, p, g, p, r, s)),
                            (f = r),
                            (d = s);
                          break;
                        case "Q":
                          (g = t[1]),
                            (p = t[2]),
                            (o = e.util.getBoundsOfCurve(f, d, g, p, g, p, t[3], t[4])),
                            (f = t[3]),
                            (d = t[4]);
                          break;
                        case "t":
                          (r = f + t[1]),
                            (s = d + t[2]),
                            null === c[0].match(/[QqTt]/)
                              ? ((g = f), (p = d))
                              : ((g = 2 * f - g), (p = 2 * d - p)),
                            (o = e.util.getBoundsOfCurve(f, d, g, p, g, p, r, s)),
                            (f = r),
                            (d = s);
                          break;
                        case "T":
                          (r = t[1]),
                            (s = t[2]),
                            null === c[0].match(/[QqTt]/)
                              ? ((g = f), (p = d))
                              : ((g = 2 * f - g), (p = 2 * d - p)),
                            (o = e.util.getBoundsOfCurve(f, d, g, p, g, p, r, s)),
                            (f = r),
                            (d = s);
                          break;
                        case "a":
                          (o = e.util.getBoundsOfArc(
                            f,
                            d,
                            t[1],
                            t[2],
                            t[3],
                            t[4],
                            t[5],
                            t[6] + f,
                            t[7] + d
                          )),
                            (f += t[6]),
                            (d += t[7]);
                          break;
                        case "A":
                          (o = e.util.getBoundsOfArc(
                            f,
                            d,
                            t[1],
                            t[2],
                            t[3],
                            t[4],
                            t[5],
                            t[6],
                            t[7]
                          )),
                            (f = t[6]),
                            (d = t[7]);
                          break;
                        case "z":
                        case "Z":
                          (f = l), (d = u);
                          break;
                      }
                      (c = t),
                        o.forEach(function (t) {
                          a.push(t.x), h.push(t.y);
                        }),
                        a.push(f),
                        h.push(d);
                    }
                    var _ = i(a) || 0,
                      y = i(h) || 0,
                      b = n(a) || 0,
                      x = n(h) || 0,
                      C = b - _,
                      w = x - y,
                      S = { left: _, top: y, width: C, height: w };
                    return S;
                  },
                })),
                (e.Path.fromObject = function (t, i) {
                  if ("string" === typeof t.sourcePath) {
                    var n = t.sourcePath;
                    e.loadSVGFromURL(n, function (e) {
                      var n = e[0];
                      n.setOptions(t), i && i(n);
                    });
                  } else e.Object._fromObject("Path", t, i, "path");
                }),
                (e.Path.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat(["d"])),
                (e.Path.fromElement = function (t, i, n) {
                  var s = e.parseAttributes(t, e.Path.ATTRIBUTE_NAMES);
                  i(new e.Path(s.d, r(s, n)));
                }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.array.min,
              n = e.util.array.max;
            e.Group ||
              ((e.Group = e.util.createClass(e.Object, e.Collection, {
                type: "group",
                strokeWidth: 0,
                subTargetCheck: !1,
                cacheProperties: [],
                useSetOnGroup: !1,
                initialize: function (t, e, i) {
                  (e = e || {}),
                    (this._objects = []),
                    i && this.callSuper("initialize", e),
                    (this._objects = t || []);
                  for (var n = this._objects.length; n--; ) this._objects[n].group = this;
                  if (i) this._updateObjectsACoords();
                  else {
                    var r = e && e.centerPoint;
                    void 0 !== e.originX && (this.originX = e.originX),
                      void 0 !== e.originY && (this.originY = e.originY),
                      r || this._calcBounds(),
                      this._updateObjectsCoords(r),
                      delete e.centerPoint,
                      this.callSuper("initialize", e);
                  }
                  this.setCoords();
                },
                _updateObjectsACoords: function () {
                  for (var t = !0, e = !0, i = this._objects.length; i--; )
                    this._objects[i].setCoords(t, e);
                },
                _updateObjectsCoords: function (t) {
                  t = t || this.getCenterPoint();
                  for (var e = this._objects.length; e--; )
                    this._updateObjectCoords(this._objects[e], t);
                },
                _updateObjectCoords: function (t, e) {
                  var i = t.left,
                    n = t.top,
                    r = !0,
                    s = !0;
                  t.set({ left: i - e.x, top: n - e.y }), (t.group = this), t.setCoords(r, s);
                },
                toString: function () {
                  return "#<fabric.Group: (" + this.complexity() + ")>";
                },
                addWithUpdate: function (t) {
                  return (
                    this._restoreObjectsState(),
                    e.util.resetObjectTransform(this),
                    t && (this._objects.push(t), (t.group = this), t._set("canvas", this.canvas)),
                    this._calcBounds(),
                    this._updateObjectsCoords(),
                    this.setCoords(),
                    (this.dirty = !0),
                    this
                  );
                },
                removeWithUpdate: function (t) {
                  return (
                    this._restoreObjectsState(),
                    e.util.resetObjectTransform(this),
                    this.remove(t),
                    this._calcBounds(),
                    this._updateObjectsCoords(),
                    this.setCoords(),
                    (this.dirty = !0),
                    this
                  );
                },
                _onObjectAdded: function (t) {
                  (this.dirty = !0), (t.group = this), t._set("canvas", this.canvas);
                },
                _onObjectRemoved: function (t) {
                  (this.dirty = !0), delete t.group;
                },
                _set: function (t, i) {
                  var n = this._objects.length;
                  if (this.useSetOnGroup) while (n--) this._objects[n].setOnGroup(t, i);
                  if ("canvas" === t) while (n--) this._objects[n]._set(t, i);
                  e.Object.prototype._set.call(this, t, i);
                },
                toObject: function (t) {
                  var i = this.includeDefaultValues,
                    n = this._objects.map(function (e) {
                      var n = e.includeDefaultValues;
                      e.includeDefaultValues = i;
                      var r = e.toObject(t);
                      return (e.includeDefaultValues = n), r;
                    }),
                    r = e.Object.prototype.toObject.call(this, t);
                  return (r.objects = n), r;
                },
                toDatalessObject: function (t) {
                  var i,
                    n = this.sourcePath;
                  if (n) i = n;
                  else {
                    var r = this.includeDefaultValues;
                    i = this._objects.map(function (e) {
                      var i = e.includeDefaultValues;
                      e.includeDefaultValues = r;
                      var n = e.toDatalessObject(t);
                      return (e.includeDefaultValues = i), n;
                    });
                  }
                  var s = e.Object.prototype.toDatalessObject.call(this, t);
                  return (s.objects = i), s;
                },
                render: function (t) {
                  (this._transformDone = !0),
                    this.callSuper("render", t),
                    (this._transformDone = !1);
                },
                shouldCache: function () {
                  var t =
                    this.objectCaching &&
                    (!this.group || this.needsItsOwnCache() || !this.group.isOnACache());
                  if (((this.ownCaching = t), t))
                    for (var e = 0, i = this._objects.length; e < i; e++)
                      if (this._objects[e].willDrawShadow()) return (this.ownCaching = !1), !1;
                  return t;
                },
                willDrawShadow: function () {
                  if (this.shadow) return e.Object.prototype.willDrawShadow.call(this);
                  for (var t = 0, i = this._objects.length; t < i; t++)
                    if (this._objects[t].willDrawShadow()) return !0;
                  return !1;
                },
                isOnACache: function () {
                  return this.ownCaching || (this.group && this.group.isOnACache());
                },
                drawObject: function (t) {
                  for (var e = 0, i = this._objects.length; e < i; e++) this._objects[e].render(t);
                  this._drawClipPath(t);
                },
                isCacheDirty: function (t) {
                  if (this.callSuper("isCacheDirty", t)) return !0;
                  if (!this.statefullCache) return !1;
                  for (var e = 0, i = this._objects.length; e < i; e++)
                    if (this._objects[e].isCacheDirty(!0)) {
                      if (this._cacheCanvas) {
                        var n = this.cacheWidth / this.zoomX,
                          r = this.cacheHeight / this.zoomY;
                        this._cacheContext.clearRect(-n / 2, -r / 2, n, r);
                      }
                      return !0;
                    }
                  return !1;
                },
                _restoreObjectsState: function () {
                  return this._objects.forEach(this._restoreObjectState, this), this;
                },
                realizeTransform: function (t) {
                  var i = t.calcTransformMatrix(),
                    n = e.util.qrDecompose(i),
                    r = new e.Point(n.translateX, n.translateY);
                  return (
                    (t.flipX = !1),
                    (t.flipY = !1),
                    t.set("scaleX", n.scaleX),
                    t.set("scaleY", n.scaleY),
                    (t.skewX = n.skewX),
                    (t.skewY = n.skewY),
                    (t.angle = n.angle),
                    t.setPositionByOrigin(r, "center", "center"),
                    t
                  );
                },
                _restoreObjectState: function (t) {
                  return this.realizeTransform(t), t.setCoords(), delete t.group, this;
                },
                destroy: function () {
                  return (
                    this._objects.forEach(function (t) {
                      t.set("dirty", !0);
                    }),
                    this._restoreObjectsState()
                  );
                },
                toActiveSelection: function () {
                  if (this.canvas) {
                    var t = this._objects,
                      i = this.canvas;
                    this._objects = [];
                    var n = this.toObject();
                    delete n.objects;
                    var r = new e.ActiveSelection([]);
                    return (
                      r.set(n),
                      (r.type = "activeSelection"),
                      i.remove(this),
                      t.forEach(function (t) {
                        (t.group = r), (t.dirty = !0), i.add(t);
                      }),
                      (r.canvas = i),
                      (r._objects = t),
                      (i._activeObject = r),
                      r.setCoords(),
                      r
                    );
                  }
                },
                ungroupOnCanvas: function () {
                  return this._restoreObjectsState();
                },
                setObjectsCoords: function () {
                  var t = !0,
                    e = !0;
                  return (
                    this.forEachObject(function (i) {
                      i.setCoords(t, e);
                    }),
                    this
                  );
                },
                _calcBounds: function (t) {
                  for (
                    var e,
                      i,
                      n,
                      r = [],
                      s = [],
                      o = ["tr", "br", "bl", "tl"],
                      a = 0,
                      h = this._objects.length,
                      c = o.length,
                      l = !0;
                    a < h;
                    ++a
                  )
                    for (e = this._objects[a], e.setCoords(l), n = 0; n < c; n++)
                      (i = o[n]), r.push(e.oCoords[i].x), s.push(e.oCoords[i].y);
                  this._getBounds(r, s, t);
                },
                _getBounds: function (t, r, s) {
                  var o = new e.Point(i(t), i(r)),
                    a = new e.Point(n(t), n(r)),
                    h = o.y || 0,
                    c = o.x || 0,
                    l = a.x - o.x || 0,
                    u = a.y - o.y || 0;
                  (this.width = l),
                    (this.height = u),
                    s || this.setPositionByOrigin({ x: c, y: h }, "left", "top");
                },
                toSVG: function (t) {
                  for (var e = [], i = 0, n = this._objects.length; i < n; i++)
                    e.push("\t", this._objects[i].toSVG(t));
                  return this._createBaseSVGMarkup(e, { reviver: t, noStyle: !0, withShadow: !0 });
                },
                toClipPathSVG: function (t) {
                  for (var e = [], i = 0, n = this._objects.length; i < n; i++)
                    e.push("\t", this._objects[i].toClipPathSVG(t));
                  return this._createBaseClipPathSVGMarkup(e, { reviver: t });
                },
              })),
              (e.Group.fromObject = function (t, i) {
                e.util.enlivenObjects(t.objects, function (n) {
                  e.util.enlivenObjects([t.clipPath], function (r) {
                    var s = e.util.object.clone(t, !0);
                    (s.clipPath = r[0]), delete s.objects, i && i(new e.Group(n, s, !0));
                  });
                });
              }));
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {});
            e.ActiveSelection ||
              ((e.ActiveSelection = e.util.createClass(e.Group, {
                type: "activeSelection",
                initialize: function (t, i) {
                  (i = i || {}), (this._objects = t || []);
                  for (var n = this._objects.length; n--; ) this._objects[n].group = this;
                  i.originX && (this.originX = i.originX),
                    i.originY && (this.originY = i.originY),
                    this._calcBounds(),
                    this._updateObjectsCoords(),
                    e.Object.prototype.initialize.call(this, i),
                    this.setCoords();
                },
                toGroup: function () {
                  var t = this._objects.concat();
                  this._objects = [];
                  var i = e.Object.prototype.toObject.call(this),
                    n = new e.Group([]);
                  if (
                    (delete i.type,
                    n.set(i),
                    t.forEach(function (t) {
                      t.canvas.remove(t), (t.group = n);
                    }),
                    (n._objects = t),
                    !this.canvas)
                  )
                    return n;
                  var r = this.canvas;
                  return r.add(n), (r._activeObject = n), n.setCoords(), n;
                },
                onDeselect: function () {
                  return this.destroy(), !1;
                },
                toString: function () {
                  return "#<fabric.ActiveSelection: (" + this.complexity() + ")>";
                },
                shouldCache: function () {
                  return !1;
                },
                isOnACache: function () {
                  return !1;
                },
                _renderControls: function (t, e, i) {
                  t.save(),
                    (t.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1),
                    this.callSuper("_renderControls", t, e),
                    (i = i || {}),
                    "undefined" === typeof i.hasControls && (i.hasControls = !1),
                    "undefined" === typeof i.hasRotatingPoint && (i.hasRotatingPoint = !1),
                    (i.forActiveSelection = !0);
                  for (var n = 0, r = this._objects.length; n < r; n++)
                    this._objects[n]._renderControls(t, i);
                  t.restore();
                },
              })),
              (e.ActiveSelection.fromObject = function (t, i) {
                e.util.enlivenObjects(t.objects, function (n) {
                  delete t.objects, i && i(new e.ActiveSelection(n, t, !0));
                });
              }));
          })(e),
          (function (t) {
            "use strict";
            var e = n.util.object.extend;
            t.fabric || (t.fabric = {}),
              t.fabric.Image
                ? n.warn("fabric.Image is already defined.")
                : ((n.Image = n.util.createClass(n.Object, {
                    type: "image",
                    crossOrigin: "",
                    strokeWidth: 0,
                    srcFromAttribute: !1,
                    _lastScaleX: 1,
                    _lastScaleY: 1,
                    _filterScalingX: 1,
                    _filterScalingY: 1,
                    minimumScaleTrigger: 0.5,
                    stateProperties: n.Object.prototype.stateProperties.concat("cropX", "cropY"),
                    cacheKey: "",
                    cropX: 0,
                    cropY: 0,
                    initialize: function (t, e) {
                      e || (e = {}),
                        (this.filters = []),
                        (this.cacheKey = "texture" + n.Object.__uid++),
                        this.callSuper("initialize", e),
                        this._initElement(t, e);
                    },
                    getElement: function () {
                      return this._element || {};
                    },
                    setElement: function (t, e) {
                      return (
                        this.removeTexture(this.cacheKey),
                        this.removeTexture(this.cacheKey + "_filtered"),
                        (this._element = t),
                        (this._originalElement = t),
                        this._initConfig(e),
                        0 !== this.filters.length && this.applyFilters(),
                        this.resizeFilter && this.applyResizeFilters(),
                        this
                      );
                    },
                    removeTexture: function (t) {
                      var e = n.filterBackend;
                      e && e.evictCachesForKey && e.evictCachesForKey(t);
                    },
                    dispose: function () {
                      this.removeTexture(this.cacheKey),
                        this.removeTexture(this.cacheKey + "_filtered"),
                        (this._cacheContext = void 0),
                        ["_originalElement", "_element", "_filteredEl", "_cacheCanvas"].forEach(
                          function (t) {
                            n.util.cleanUpJsdomNode(this[t]), (this[t] = void 0);
                          }.bind(this)
                        );
                    },
                    setCrossOrigin: function (t) {
                      return (this.crossOrigin = t), (this._element.crossOrigin = t), this;
                    },
                    getOriginalSize: function () {
                      var t = this.getElement();
                      return {
                        width: t.naturalWidth || t.width,
                        height: t.naturalHeight || t.height,
                      };
                    },
                    _stroke: function (t) {
                      if (this.stroke && 0 !== this.strokeWidth) {
                        var e = this.width / 2,
                          i = this.height / 2;
                        t.beginPath(),
                          t.moveTo(-e, -i),
                          t.lineTo(e, -i),
                          t.lineTo(e, i),
                          t.lineTo(-e, i),
                          t.lineTo(-e, -i),
                          t.closePath();
                      }
                    },
                    _renderDashedStroke: function (t) {
                      var e = -this.width / 2,
                        i = -this.height / 2,
                        r = this.width,
                        s = this.height;
                      t.save(),
                        this._setStrokeStyles(t, this),
                        t.beginPath(),
                        n.util.drawDashedLine(t, e, i, e + r, i, this.strokeDashArray),
                        n.util.drawDashedLine(t, e + r, i, e + r, i + s, this.strokeDashArray),
                        n.util.drawDashedLine(t, e + r, i + s, e, i + s, this.strokeDashArray),
                        n.util.drawDashedLine(t, e, i + s, e, i, this.strokeDashArray),
                        t.closePath(),
                        t.restore();
                    },
                    toObject: function (t) {
                      var i = [];
                      this.filters.forEach(function (t) {
                        t && i.push(t.toObject());
                      });
                      var n = e(
                        this.callSuper("toObject", ["crossOrigin", "cropX", "cropY"].concat(t)),
                        { src: this.getSrc(), filters: i }
                      );
                      return (
                        this.resizeFilter && (n.resizeFilter = this.resizeFilter.toObject()), n
                      );
                    },
                    hasCrop: function () {
                      return (
                        this.cropX ||
                        this.cropY ||
                        this.width < this._element.width ||
                        this.height < this._element.height
                      );
                    },
                    _toSVG: function () {
                      var t,
                        e = [],
                        i = [],
                        r = -this.width / 2,
                        s = -this.height / 2,
                        o = "";
                      if (this.hasCrop()) {
                        var a = n.Object.__uid++;
                        e.push(
                          '<clipPath id="imageCrop_' + a + '">\n',
                          '\t<rect x="' +
                            r +
                            '" y="' +
                            s +
                            '" width="' +
                            this.width +
                            '" height="' +
                            this.height +
                            '" />\n',
                          "</clipPath>\n"
                        ),
                          (o = ' clip-path="url(#imageCrop_' + a + ')" ');
                      }
                      if (
                        (i.push(
                          "\t<image ",
                          "COMMON_PARTS",
                          'xlink:href="',
                          this.getSvgSrc(!0),
                          '" x="',
                          r - this.cropX,
                          '" y="',
                          s - this.cropY,
                          '" width="',
                          this._element.width || this._element.naturalWidth,
                          '" height="',
                          this._element.height || this._element.height,
                          '"',
                          o,
                          "></image>\n"
                        ),
                        this.stroke || this.strokeDashArray)
                      ) {
                        var h = this.fill;
                        (this.fill = null),
                          (t = [
                            "\t<rect ",
                            'x="',
                            r,
                            '" y="',
                            s,
                            '" width="',
                            this.width,
                            '" height="',
                            this.height,
                            '" style="',
                            this.getSvgStyles(),
                            '"/>\n',
                          ]),
                          (this.fill = h);
                      }
                      return (e = "fill" !== this.paintFirst ? e.concat(t, i) : e.concat(i, t)), e;
                    },
                    getSrc: function (t) {
                      var e = t ? this._element : this._originalElement;
                      return e
                        ? e.toDataURL
                          ? e.toDataURL()
                          : this.srcFromAttribute
                          ? e.getAttribute("src")
                          : e.src
                        : this.src || "";
                    },
                    setSrc: function (t, e, i) {
                      return (
                        n.util.loadImage(
                          t,
                          function (t) {
                            this.setElement(t, i), this._setWidthHeight(), e && e(this);
                          },
                          this,
                          i && i.crossOrigin
                        ),
                        this
                      );
                    },
                    toString: function () {
                      return '#<fabric.Image: { src: "' + this.getSrc() + '" }>';
                    },
                    applyResizeFilters: function () {
                      var t = this.resizeFilter,
                        e = this.minimumScaleTrigger,
                        i = this.getTotalObjectScaling(),
                        r = i.scaleX,
                        s = i.scaleY,
                        o = this._filteredEl || this._originalElement;
                      if ((this.group && this.set("dirty", !0), !t || (r > e && s > e)))
                        return (
                          (this._element = o),
                          (this._filterScalingX = 1),
                          (this._filterScalingY = 1),
                          (this._lastScaleX = r),
                          void (this._lastScaleY = s)
                        );
                      n.filterBackend || (n.filterBackend = n.initFilterBackend());
                      var a = n.util.createCanvasElement(),
                        h = this._filteredEl ? this.cacheKey + "_filtered" : this.cacheKey,
                        c = o.width,
                        l = o.height;
                      (a.width = c),
                        (a.height = l),
                        (this._element = a),
                        (this._lastScaleX = t.scaleX = r),
                        (this._lastScaleY = t.scaleY = s),
                        n.filterBackend.applyFilters([t], o, c, l, this._element, h),
                        (this._filterScalingX = a.width / this._originalElement.width),
                        (this._filterScalingY = a.height / this._originalElement.height);
                    },
                    applyFilters: function (t) {
                      if (
                        ((t = t || this.filters || []),
                        (t = t.filter(function (t) {
                          return t && !t.isNeutralState();
                        })),
                        this.set("dirty", !0),
                        this.removeTexture(this.cacheKey + "_filtered"),
                        0 === t.length)
                      )
                        return (
                          (this._element = this._originalElement),
                          (this._filteredEl = null),
                          (this._filterScalingX = 1),
                          (this._filterScalingY = 1),
                          this
                        );
                      var e = this._originalElement,
                        i = e.naturalWidth || e.width,
                        r = e.naturalHeight || e.height;
                      if (this._element === this._originalElement) {
                        var s = n.util.createCanvasElement();
                        (s.width = i), (s.height = r), (this._element = s), (this._filteredEl = s);
                      } else
                        (this._element = this._filteredEl),
                          this._filteredEl.getContext("2d").clearRect(0, 0, i, r),
                          (this._lastScaleX = 1),
                          (this._lastScaleY = 1);
                      return (
                        n.filterBackend || (n.filterBackend = n.initFilterBackend()),
                        n.filterBackend.applyFilters(
                          t,
                          this._originalElement,
                          i,
                          r,
                          this._element,
                          this.cacheKey
                        ),
                        (this._originalElement.width === this._element.width &&
                          this._originalElement.height === this._element.height) ||
                          ((this._filterScalingX =
                            this._element.width / this._originalElement.width),
                          (this._filterScalingY =
                            this._element.height / this._originalElement.height)),
                        this
                      );
                    },
                    _render: function (t) {
                      !0 !== this.isMoving &&
                        this.resizeFilter &&
                        this._needsResize() &&
                        this.applyResizeFilters(),
                        this._stroke(t),
                        this._renderPaintInOrder(t);
                    },
                    shouldCache: function () {
                      return (
                        (this.ownCaching = this.objectCaching && this.needsItsOwnCache()),
                        this.ownCaching
                      );
                    },
                    _renderFill: function (t) {
                      var e = this._element,
                        i = this.width,
                        n = this.height,
                        r = Math.min(e.naturalWidth || e.width, i * this._filterScalingX),
                        s = Math.min(e.naturalHeight || e.height, n * this._filterScalingY),
                        o = -i / 2,
                        a = -n / 2,
                        h = Math.max(0, this.cropX * this._filterScalingX),
                        c = Math.max(0, this.cropY * this._filterScalingY);
                      e && t.drawImage(e, h, c, r, s, o, a, i, n);
                    },
                    _needsResize: function () {
                      var t = this.getTotalObjectScaling();
                      return t.scaleX !== this._lastScaleX || t.scaleY !== this._lastScaleY;
                    },
                    _resetWidthHeight: function () {
                      this.set(this.getOriginalSize());
                    },
                    _initElement: function (t, e) {
                      this.setElement(n.util.getById(t), e),
                        n.util.addClass(this.getElement(), n.Image.CSS_CANVAS);
                    },
                    _initConfig: function (t) {
                      t || (t = {}),
                        this.setOptions(t),
                        this._setWidthHeight(t),
                        this._element &&
                          this.crossOrigin &&
                          (this._element.crossOrigin = this.crossOrigin);
                    },
                    _initFilters: function (t, e) {
                      t && t.length
                        ? n.util.enlivenObjects(
                            t,
                            function (t) {
                              e && e(t);
                            },
                            "fabric.Image.filters"
                          )
                        : e && e();
                    },
                    _setWidthHeight: function (t) {
                      t || (t = {});
                      var e = this.getElement();
                      (this.width = t.width || e.naturalWidth || e.width || 0),
                        (this.height = t.height || e.naturalHeight || e.height || 0);
                    },
                    parsePreserveAspectRatioAttribute: function () {
                      var t,
                        e = n.util.parsePreserveAspectRatioAttribute(
                          this.preserveAspectRatio || ""
                        ),
                        i = this._element.width,
                        r = this._element.height,
                        s = 1,
                        o = 1,
                        a = 0,
                        h = 0,
                        c = 0,
                        l = 0,
                        u = this.width,
                        f = this.height,
                        d = { width: u, height: f };
                      return (
                        !e || ("none" === e.alignX && "none" === e.alignY)
                          ? ((s = u / i), (o = f / r))
                          : ("meet" === e.meetOrSlice &&
                              ((s = o = n.util.findScaleToFit(this._element, d)),
                              (t = (u - i * s) / 2),
                              "Min" === e.alignX && (a = -t),
                              "Max" === e.alignX && (a = t),
                              (t = (f - r * o) / 2),
                              "Min" === e.alignY && (h = -t),
                              "Max" === e.alignY && (h = t)),
                            "slice" === e.meetOrSlice &&
                              ((s = o = n.util.findScaleToCover(this._element, d)),
                              (t = i - u / s),
                              "Mid" === e.alignX && (c = t / 2),
                              "Max" === e.alignX && (c = t),
                              (t = r - f / o),
                              "Mid" === e.alignY && (l = t / 2),
                              "Max" === e.alignY && (l = t),
                              (i = u / s),
                              (r = f / o))),
                        {
                          width: i,
                          height: r,
                          scaleX: s,
                          scaleY: o,
                          offsetLeft: a,
                          offsetTop: h,
                          cropX: c,
                          cropY: l,
                        }
                      );
                    },
                  })),
                  (n.Image.CSS_CANVAS = "canvas-img"),
                  (n.Image.prototype.getSvgSrc = n.Image.prototype.getSrc),
                  (n.Image.fromObject = function (t, e) {
                    var i = n.util.object.clone(t);
                    n.util.loadImage(
                      i.src,
                      function (t, r) {
                        r
                          ? e && e(null, r)
                          : n.Image.prototype._initFilters.call(i, i.filters, function (r) {
                              (i.filters = r || []),
                                n.Image.prototype._initFilters.call(
                                  i,
                                  [i.resizeFilter],
                                  function (r) {
                                    (i.resizeFilter = r[0]),
                                      n.util.enlivenObjects([i.clipPath], function (r) {
                                        i.clipPath = r[0];
                                        var s = new n.Image(t, i);
                                        e(s);
                                      });
                                  }
                                );
                            });
                      },
                      null,
                      i.crossOrigin
                    );
                  }),
                  (n.Image.fromURL = function (t, e, i) {
                    n.util.loadImage(
                      t,
                      function (t) {
                        e && e(new n.Image(t, i));
                      },
                      null,
                      i && i.crossOrigin
                    );
                  }),
                  (n.Image.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat(
                    "x y width height preserveAspectRatio xlink:href crossOrigin".split(" ")
                  )),
                  (n.Image.fromElement = function (t, i, r) {
                    var s = n.parseAttributes(t, n.Image.ATTRIBUTE_NAMES);
                    n.Image.fromURL(s["xlink:href"], i, e(r ? n.util.object.clone(r) : {}, s));
                  }));
          })(e),
          n.util.object.extend(n.Object.prototype, {
            _getAngleValueForStraighten: function () {
              var t = this.angle % 360;
              return t > 0 ? 90 * Math.round((t - 1) / 90) : 90 * Math.round(t / 90);
            },
            straighten: function () {
              return this.rotate(this._getAngleValueForStraighten()), this;
            },
            fxStraighten: function (t) {
              t = t || {};
              var e = function () {},
                i = t.onComplete || e,
                r = t.onChange || e,
                s = this;
              return (
                n.util.animate({
                  startValue: this.get("angle"),
                  endValue: this._getAngleValueForStraighten(),
                  duration: this.FX_DURATION,
                  onChange: function (t) {
                    s.rotate(t), r();
                  },
                  onComplete: function () {
                    s.setCoords(), i();
                  },
                }),
                this
              );
            },
          }),
          n.util.object.extend(n.StaticCanvas.prototype, {
            straightenObject: function (t) {
              return t.straighten(), this.requestRenderAll(), this;
            },
            fxStraightenObject: function (t) {
              return t.fxStraighten({ onChange: this.requestRenderAllBound }), this;
            },
          }),
          (function () {
            "use strict";
            function t(t, e) {
              var i = "precision " + e + " float;\nvoid main(){}",
                n = t.createShader(t.FRAGMENT_SHADER);
              return (
                t.shaderSource(n, i),
                t.compileShader(n),
                !!t.getShaderParameter(n, t.COMPILE_STATUS)
              );
            }
            function e(t) {
              t && t.tileSize && (this.tileSize = t.tileSize),
                this.setupGLContext(this.tileSize, this.tileSize),
                this.captureGPUInfo();
            }
            (n.isWebglSupported = function (e) {
              if (n.isLikelyNode) return !1;
              e = e || n.WebglFilterBackend.prototype.tileSize;
              var i = document.createElement("canvas"),
                r = i.getContext("webgl") || i.getContext("experimental-webgl"),
                s = !1;
              if (r) {
                (n.maxTextureSize = r.getParameter(r.MAX_TEXTURE_SIZE)),
                  (s = n.maxTextureSize >= e);
                for (var o = ["highp", "mediump", "lowp"], a = 0; a < 3; a++)
                  if (t(r, o[a])) {
                    n.webGlPrecision = o[a];
                    break;
                  }
              }
              return (this.isSupported = s), s;
            }),
              (n.WebglFilterBackend = e),
              (e.prototype = {
                tileSize: 2048,
                resources: {},
                setupGLContext: function (t, e) {
                  this.dispose(),
                    this.createWebGLCanvas(t, e),
                    (this.aPosition = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1])),
                    this.chooseFastestCopyGLTo2DMethod(t, e);
                },
                chooseFastestCopyGLTo2DMethod: function (t, e) {
                  var i,
                    r = "undefined" !== typeof window.performance;
                  try {
                    new ImageData(1, 1), (i = !0);
                  } catch (p) {
                    i = !1;
                  }
                  var a = "undefined" !== typeof ArrayBuffer,
                    h = "undefined" !== typeof Uint8ClampedArray;
                  if (r && i && a && h) {
                    var c,
                      l,
                      u,
                      f = n.util.createCanvasElement(),
                      d = new ArrayBuffer(t * e * 4),
                      g = {
                        imageBuffer: d,
                        destinationWidth: t,
                        destinationHeight: e,
                        targetCanvas: f,
                      };
                    (f.width = t),
                      (f.height = e),
                      (c = window.performance.now()),
                      s.call(g, this.gl, g),
                      (l = window.performance.now() - c),
                      (c = window.performance.now()),
                      o.call(g, this.gl, g),
                      (u = window.performance.now() - c),
                      l > u
                        ? ((this.imageBuffer = d), (this.copyGLTo2D = o))
                        : (this.copyGLTo2D = s);
                  }
                },
                createWebGLCanvas: function (t, e) {
                  var i = n.util.createCanvasElement();
                  (i.width = t), (i.height = e);
                  var r = {
                      alpha: !0,
                      premultipliedAlpha: !1,
                      depth: !1,
                      stencil: !1,
                      antialias: !1,
                    },
                    s = i.getContext("webgl", r);
                  s || (s = i.getContext("experimental-webgl", r)),
                    s && (s.clearColor(0, 0, 0, 0), (this.canvas = i), (this.gl = s));
                },
                applyFilters: function (t, e, i, n, s, o) {
                  var a,
                    h = this.gl;
                  o && (a = this.getCachedTexture(o, e));
                  var c = {
                      originalWidth: e.width || e.originalWidth,
                      originalHeight: e.height || e.originalHeight,
                      sourceWidth: i,
                      sourceHeight: n,
                      destinationWidth: i,
                      destinationHeight: n,
                      context: h,
                      sourceTexture: this.createTexture(h, i, n, !a && e),
                      targetTexture: this.createTexture(h, i, n),
                      originalTexture: a || this.createTexture(h, i, n, !a && e),
                      passes: t.length,
                      webgl: !0,
                      aPosition: this.aPosition,
                      programCache: this.programCache,
                      pass: 0,
                      filterBackend: this,
                      targetCanvas: s,
                    },
                    l = h.createFramebuffer();
                  return (
                    h.bindFramebuffer(h.FRAMEBUFFER, l),
                    t.forEach(function (t) {
                      t && t.applyTo(c);
                    }),
                    r(c),
                    this.copyGLTo2D(h, c),
                    h.bindTexture(h.TEXTURE_2D, null),
                    h.deleteTexture(c.sourceTexture),
                    h.deleteTexture(c.targetTexture),
                    h.deleteFramebuffer(l),
                    s.getContext("2d").setTransform(1, 0, 0, 1, 0, 0),
                    c
                  );
                },
                dispose: function () {
                  this.canvas && ((this.canvas = null), (this.gl = null)), this.clearWebGLCaches();
                },
                clearWebGLCaches: function () {
                  (this.programCache = {}), (this.textureCache = {});
                },
                createTexture: function (t, e, i, n) {
                  var r = t.createTexture();
                  return (
                    t.bindTexture(t.TEXTURE_2D, r),
                    t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST),
                    t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST),
                    t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE),
                    t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE),
                    n
                      ? t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, n)
                      : t.texImage2D(
                          t.TEXTURE_2D,
                          0,
                          t.RGBA,
                          e,
                          i,
                          0,
                          t.RGBA,
                          t.UNSIGNED_BYTE,
                          null
                        ),
                    r
                  );
                },
                getCachedTexture: function (t, e) {
                  if (this.textureCache[t]) return this.textureCache[t];
                  var i = this.createTexture(this.gl, e.width, e.height, e);
                  return (this.textureCache[t] = i), i;
                },
                evictCachesForKey: function (t) {
                  this.textureCache[t] &&
                    (this.gl.deleteTexture(this.textureCache[t]), delete this.textureCache[t]);
                },
                copyGLTo2D: s,
                captureGPUInfo: function () {
                  if (this.gpuInfo) return this.gpuInfo;
                  var t = this.gl,
                    e = { renderer: "", vendor: "" };
                  if (!t) return e;
                  var i = t.getExtension("WEBGL_debug_renderer_info");
                  if (i) {
                    var n = t.getParameter(i.UNMASKED_RENDERER_WEBGL),
                      r = t.getParameter(i.UNMASKED_VENDOR_WEBGL);
                    n && (e.renderer = n.toLowerCase()), r && (e.vendor = r.toLowerCase());
                  }
                  return (this.gpuInfo = e), e;
                },
              });
          })(),
          (function () {
            "use strict";
            var t = function () {};
            function e() {}
            (n.Canvas2dFilterBackend = e),
              (e.prototype = {
                evictCachesForKey: t,
                dispose: t,
                clearWebGLCaches: t,
                resources: {},
                applyFilters: function (t, e, i, n, r) {
                  var s = r.getContext("2d");
                  s.drawImage(e, 0, 0, i, n);
                  var o = s.getImageData(0, 0, i, n),
                    a = s.getImageData(0, 0, i, n),
                    h = {
                      sourceWidth: i,
                      sourceHeight: n,
                      imageData: o,
                      originalEl: e,
                      originalImageData: a,
                      canvasEl: r,
                      ctx: s,
                      filterBackend: this,
                    };
                  return (
                    t.forEach(function (t) {
                      t.applyTo(h);
                    }),
                    (h.imageData.width === i && h.imageData.height === n) ||
                      ((r.width = h.imageData.width), (r.height = h.imageData.height)),
                    s.putImageData(h.imageData, 0, 0),
                    h
                  );
                },
              });
          })(),
          (n.Image = n.Image || {}),
          (n.Image.filters = n.Image.filters || {}),
          (n.Image.filters.BaseFilter = n.util.createClass({
            type: "BaseFilter",
            vertexSource:
              "attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",
            fragmentSource:
              "precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",
            initialize: function (t) {
              t && this.setOptions(t);
            },
            setOptions: function (t) {
              for (var e in t) this[e] = t[e];
            },
            createProgram: function (t, e, i) {
              (e = e || this.fragmentSource),
                (i = i || this.vertexSource),
                "highp" !== n.webGlPrecision &&
                  (e = e.replace(
                    /precision highp float/g,
                    "precision " + n.webGlPrecision + " float"
                  ));
              var r = t.createShader(t.VERTEX_SHADER);
              if (
                (t.shaderSource(r, i),
                t.compileShader(r),
                !t.getShaderParameter(r, t.COMPILE_STATUS))
              )
                throw new Error(
                  "Vertex shader compile error for " + this.type + ": " + t.getShaderInfoLog(r)
                );
              var s = t.createShader(t.FRAGMENT_SHADER);
              if (
                (t.shaderSource(s, e),
                t.compileShader(s),
                !t.getShaderParameter(s, t.COMPILE_STATUS))
              )
                throw new Error(
                  "Fragment shader compile error for " + this.type + ": " + t.getShaderInfoLog(s)
                );
              var o = t.createProgram();
              if (
                (t.attachShader(o, r),
                t.attachShader(o, s),
                t.linkProgram(o),
                !t.getProgramParameter(o, t.LINK_STATUS))
              )
                throw new Error('Shader link error for "${this.type}" ' + t.getProgramInfoLog(o));
              var a = this.getAttributeLocations(t, o),
                h = this.getUniformLocations(t, o) || {};
              return (
                (h.uStepW = t.getUniformLocation(o, "uStepW")),
                (h.uStepH = t.getUniformLocation(o, "uStepH")),
                { program: o, attributeLocations: a, uniformLocations: h }
              );
            },
            getAttributeLocations: function (t, e) {
              return { aPosition: t.getAttribLocation(e, "aPosition") };
            },
            getUniformLocations: function () {
              return {};
            },
            sendAttributeData: function (t, e, i) {
              var n = e.aPosition,
                r = t.createBuffer();
              t.bindBuffer(t.ARRAY_BUFFER, r),
                t.enableVertexAttribArray(n),
                t.vertexAttribPointer(n, 2, t.FLOAT, !1, 0, 0),
                t.bufferData(t.ARRAY_BUFFER, i, t.STATIC_DRAW);
            },
            _setupFrameBuffer: function (t) {
              var e,
                i,
                n = t.context;
              t.passes > 1
                ? ((e = t.destinationWidth),
                  (i = t.destinationHeight),
                  (t.sourceWidth === e && t.sourceHeight === i) ||
                    (n.deleteTexture(t.targetTexture),
                    (t.targetTexture = t.filterBackend.createTexture(n, e, i))),
                  n.framebufferTexture2D(
                    n.FRAMEBUFFER,
                    n.COLOR_ATTACHMENT0,
                    n.TEXTURE_2D,
                    t.targetTexture,
                    0
                  ))
                : (n.bindFramebuffer(n.FRAMEBUFFER, null), n.finish());
            },
            _swapTextures: function (t) {
              t.passes--, t.pass++;
              var e = t.targetTexture;
              (t.targetTexture = t.sourceTexture), (t.sourceTexture = e);
            },
            isNeutralState: function () {
              var t = this.mainParameter,
                e = n.Image.filters[this.type].prototype;
              if (t) {
                if (Array.isArray(e[t])) {
                  for (var i = e[t].length; i--; ) if (this[t][i] !== e[t][i]) return !1;
                  return !0;
                }
                return e[t] === this[t];
              }
              return !1;
            },
            applyTo: function (t) {
              t.webgl
                ? (this._setupFrameBuffer(t), this.applyToWebGL(t), this._swapTextures(t))
                : this.applyTo2d(t);
            },
            retrieveShader: function (t) {
              return (
                t.programCache.hasOwnProperty(this.type) ||
                  (t.programCache[this.type] = this.createProgram(t.context)),
                t.programCache[this.type]
              );
            },
            applyToWebGL: function (t) {
              var e = t.context,
                i = this.retrieveShader(t);
              0 === t.pass && t.originalTexture
                ? e.bindTexture(e.TEXTURE_2D, t.originalTexture)
                : e.bindTexture(e.TEXTURE_2D, t.sourceTexture),
                e.useProgram(i.program),
                this.sendAttributeData(e, i.attributeLocations, t.aPosition),
                e.uniform1f(i.uniformLocations.uStepW, 1 / t.sourceWidth),
                e.uniform1f(i.uniformLocations.uStepH, 1 / t.sourceHeight),
                this.sendUniformData(e, i.uniformLocations),
                e.viewport(0, 0, t.destinationWidth, t.destinationHeight),
                e.drawArrays(e.TRIANGLE_STRIP, 0, 4);
            },
            bindAdditionalTexture: function (t, e, i) {
              t.activeTexture(i), t.bindTexture(t.TEXTURE_2D, e), t.activeTexture(t.TEXTURE0);
            },
            unbindAdditionalTexture: function (t, e) {
              t.activeTexture(e), t.bindTexture(t.TEXTURE_2D, null), t.activeTexture(t.TEXTURE0);
            },
            getMainParameter: function () {
              return this[this.mainParameter];
            },
            setMainParameter: function (t) {
              this[this.mainParameter] = t;
            },
            sendUniformData: function () {},
            createHelpLayer: function (t) {
              if (!t.helpLayer) {
                var e = document.createElement("canvas");
                (e.width = t.sourceWidth), (e.height = t.sourceHeight), (t.helpLayer = e);
              }
            },
            toObject: function () {
              var t = { type: this.type },
                e = this.mainParameter;
              return e && (t[e] = this[e]), t;
            },
            toJSON: function () {
              return this.toObject();
            },
          })),
          (n.Image.filters.BaseFilter.fromObject = function (t, e) {
            var i = new n.Image.filters[t.type](t);
            return e && e(i), i;
          }),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.ColorMatrix = n(i.BaseFilter, {
              type: "ColorMatrix",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",
              matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
              mainParameter: "matrix",
              colorsOnly: !0,
              initialize: function (t) {
                this.callSuper("initialize", t), (this.matrix = this.matrix.slice(0));
              },
              applyTo2d: function (t) {
                var e,
                  i,
                  n,
                  r,
                  s,
                  o = t.imageData,
                  a = o.data,
                  h = a.length,
                  c = this.matrix,
                  l = this.colorsOnly;
                for (s = 0; s < h; s += 4)
                  (e = a[s]),
                    (i = a[s + 1]),
                    (n = a[s + 2]),
                    l
                      ? ((a[s] = e * c[0] + i * c[1] + n * c[2] + 255 * c[4]),
                        (a[s + 1] = e * c[5] + i * c[6] + n * c[7] + 255 * c[9]),
                        (a[s + 2] = e * c[10] + i * c[11] + n * c[12] + 255 * c[14]))
                      : ((r = a[s + 3]),
                        (a[s] = e * c[0] + i * c[1] + n * c[2] + r * c[3] + 255 * c[4]),
                        (a[s + 1] = e * c[5] + i * c[6] + n * c[7] + r * c[8] + 255 * c[9]),
                        (a[s + 2] = e * c[10] + i * c[11] + n * c[12] + r * c[13] + 255 * c[14]),
                        (a[s + 3] = e * c[15] + i * c[16] + n * c[17] + r * c[18] + 255 * c[19]));
              },
              getUniformLocations: function (t, e) {
                return {
                  uColorMatrix: t.getUniformLocation(e, "uColorMatrix"),
                  uConstants: t.getUniformLocation(e, "uConstants"),
                };
              },
              sendUniformData: function (t, e) {
                var i = this.matrix,
                  n = [
                    i[0],
                    i[1],
                    i[2],
                    i[3],
                    i[5],
                    i[6],
                    i[7],
                    i[8],
                    i[10],
                    i[11],
                    i[12],
                    i[13],
                    i[15],
                    i[16],
                    i[17],
                    i[18],
                  ],
                  r = [i[4], i[9], i[14], i[19]];
                t.uniformMatrix4fv(e.uColorMatrix, !1, n), t.uniform4fv(e.uConstants, r);
              },
            })),
              (e.Image.filters.ColorMatrix.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Brightness = n(i.BaseFilter, {
              type: "Brightness",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform float uBrightness;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += uBrightness;\ngl_FragColor = color;\n}",
              brightness: 0,
              mainParameter: "brightness",
              applyTo2d: function (t) {
                if (0 !== this.brightness) {
                  var e,
                    i = t.imageData,
                    n = i.data,
                    r = n.length,
                    s = Math.round(255 * this.brightness);
                  for (e = 0; e < r; e += 4)
                    (n[e] = n[e] + s), (n[e + 1] = n[e + 1] + s), (n[e + 2] = n[e + 2] + s);
                }
              },
              getUniformLocations: function (t, e) {
                return { uBrightness: t.getUniformLocation(e, "uBrightness") };
              },
              sendUniformData: function (t, e) {
                t.uniform1f(e.uBrightness, this.brightness);
              },
            })),
              (e.Image.filters.Brightness.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend,
              n = e.Image.filters,
              r = e.util.createClass;
            (n.Convolute = r(n.BaseFilter, {
              type: "Convolute",
              opaque: !1,
              matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],
              fragmentSource: {
                Convolute_3_1:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n}\n}\ngl_FragColor = color;\n}",
                Convolute_3_0:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",
                Convolute_5_1:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n}\n}\ngl_FragColor = color;\n}",
                Convolute_5_0:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",
                Convolute_7_1:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n}\n}\ngl_FragColor = color;\n}",
                Convolute_7_0:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",
                Convolute_9_1:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n}\n}\ngl_FragColor = color;\n}",
                Convolute_9_0:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",
              },
              retrieveShader: function (t) {
                var e = Math.sqrt(this.matrix.length),
                  i = this.type + "_" + e + "_" + (this.opaque ? 1 : 0),
                  n = this.fragmentSource[i];
                return (
                  t.programCache.hasOwnProperty(i) ||
                    (t.programCache[i] = this.createProgram(t.context, n)),
                  t.programCache[i]
                );
              },
              applyTo2d: function (t) {
                var e,
                  i,
                  n,
                  r,
                  s,
                  o,
                  a,
                  h,
                  c,
                  l,
                  u,
                  f,
                  d,
                  g = t.imageData,
                  p = g.data,
                  m = this.matrix,
                  v = Math.round(Math.sqrt(m.length)),
                  _ = Math.floor(v / 2),
                  y = g.width,
                  b = g.height,
                  x = t.ctx.createImageData(y, b),
                  C = x.data,
                  w = this.opaque ? 1 : 0;
                for (u = 0; u < b; u++)
                  for (l = 0; l < y; l++) {
                    for (s = 4 * (u * y + l), e = 0, i = 0, n = 0, r = 0, d = 0; d < v; d++)
                      for (f = 0; f < v; f++)
                        (a = u + d - _),
                          (o = l + f - _),
                          a < 0 ||
                            a > b ||
                            o < 0 ||
                            o > y ||
                            ((h = 4 * (a * y + o)),
                            (c = m[d * v + f]),
                            (e += p[h] * c),
                            (i += p[h + 1] * c),
                            (n += p[h + 2] * c),
                            w || (r += p[h + 3] * c));
                    (C[s] = e), (C[s + 1] = i), (C[s + 2] = n), (C[s + 3] = w ? p[s + 3] : r);
                  }
                t.imageData = x;
              },
              getUniformLocations: function (t, e) {
                return {
                  uMatrix: t.getUniformLocation(e, "uMatrix"),
                  uOpaque: t.getUniformLocation(e, "uOpaque"),
                  uHalfSize: t.getUniformLocation(e, "uHalfSize"),
                  uSize: t.getUniformLocation(e, "uSize"),
                };
              },
              sendUniformData: function (t, e) {
                t.uniform1fv(e.uMatrix, this.matrix);
              },
              toObject: function () {
                return i(this.callSuper("toObject"), { opaque: this.opaque, matrix: this.matrix });
              },
            })),
              (e.Image.filters.Convolute.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Grayscale = n(i.BaseFilter, {
              type: "Grayscale",
              fragmentSource: {
                average:
                  "precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",
                lightness:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",
                luminosity:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}",
              },
              mode: "average",
              mainParameter: "mode",
              applyTo2d: function (t) {
                var e,
                  i,
                  n = t.imageData,
                  r = n.data,
                  s = r.length,
                  o = this.mode;
                for (e = 0; e < s; e += 4)
                  "average" === o
                    ? (i = (r[e] + r[e + 1] + r[e + 2]) / 3)
                    : "lightness" === o
                    ? (i =
                        (Math.min(r[e], r[e + 1], r[e + 2]) + Math.max(r[e], r[e + 1], r[e + 2])) /
                        2)
                    : "luminosity" === o && (i = 0.21 * r[e] + 0.72 * r[e + 1] + 0.07 * r[e + 2]),
                    (r[e] = i),
                    (r[e + 1] = i),
                    (r[e + 2] = i);
              },
              retrieveShader: function (t) {
                var e = this.type + "_" + this.mode;
                if (!t.programCache.hasOwnProperty(e)) {
                  var i = this.fragmentSource[this.mode];
                  t.programCache[e] = this.createProgram(t.context, i);
                }
                return t.programCache[e];
              },
              getUniformLocations: function (t, e) {
                return { uMode: t.getUniformLocation(e, "uMode") };
              },
              sendUniformData: function (t, e) {
                var i = 1;
                t.uniform1i(e.uMode, i);
              },
              isNeutralState: function () {
                return !1;
              },
            })),
              (e.Image.filters.Grayscale.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Invert = n(i.BaseFilter, {
              type: "Invert",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform int uInvert;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nif (uInvert == 1) {\ngl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n} else {\ngl_FragColor = color;\n}\n}",
              invert: !0,
              mainParameter: "invert",
              applyTo2d: function (t) {
                var e,
                  i = t.imageData,
                  n = i.data,
                  r = n.length;
                for (e = 0; e < r; e += 4)
                  (n[e] = 255 - n[e]), (n[e + 1] = 255 - n[e + 1]), (n[e + 2] = 255 - n[e + 2]);
              },
              isNeutralState: function () {
                return !this.invert;
              },
              getUniformLocations: function (t, e) {
                return { uInvert: t.getUniformLocation(e, "uInvert") };
              },
              sendUniformData: function (t, e) {
                t.uniform1i(e.uInvert, this.invert);
              },
            })),
              (e.Image.filters.Invert.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend,
              n = e.Image.filters,
              r = e.util.createClass;
            (n.Noise = r(n.BaseFilter, {
              type: "Noise",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform float uStepH;\nuniform float uNoise;\nuniform float uSeed;\nvarying vec2 vTexCoord;\nfloat rand(vec2 co, float seed, float vScale) {\nreturn fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n}\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\ngl_FragColor = color;\n}",
              mainParameter: "noise",
              noise: 0,
              applyTo2d: function (t) {
                if (0 !== this.noise) {
                  var e,
                    i,
                    n = t.imageData,
                    r = n.data,
                    s = r.length,
                    o = this.noise;
                  for (e = 0, s = r.length; e < s; e += 4)
                    (i = (0.5 - Math.random()) * o), (r[e] += i), (r[e + 1] += i), (r[e + 2] += i);
                }
              },
              getUniformLocations: function (t, e) {
                return {
                  uNoise: t.getUniformLocation(e, "uNoise"),
                  uSeed: t.getUniformLocation(e, "uSeed"),
                };
              },
              sendUniformData: function (t, e) {
                t.uniform1f(e.uNoise, this.noise / 255), t.uniform1f(e.uSeed, Math.random());
              },
              toObject: function () {
                return i(this.callSuper("toObject"), { noise: this.noise });
              },
            })),
              (e.Image.filters.Noise.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Pixelate = n(i.BaseFilter, {
              type: "Pixelate",
              blocksize: 4,
              mainParameter: "blocksize",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform float uBlocksize;\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nfloat blockW = uBlocksize * uStepW;\nfloat blockH = uBlocksize * uStepW;\nint posX = int(vTexCoord.x / blockW);\nint posY = int(vTexCoord.y / blockH);\nfloat fposX = float(posX);\nfloat fposY = float(posY);\nvec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\nvec4 color = texture2D(uTexture, squareCoords);\ngl_FragColor = color;\n}",
              applyTo2d: function (t) {
                var e,
                  i,
                  n,
                  r,
                  s,
                  o,
                  a,
                  h,
                  c,
                  l,
                  u,
                  f = t.imageData,
                  d = f.data,
                  g = f.height,
                  p = f.width;
                for (i = 0; i < g; i += this.blocksize)
                  for (n = 0; n < p; n += this.blocksize)
                    for (
                      e = 4 * i * p + 4 * n,
                        r = d[e],
                        s = d[e + 1],
                        o = d[e + 2],
                        a = d[e + 3],
                        l = Math.min(i + this.blocksize, g),
                        u = Math.min(n + this.blocksize, p),
                        h = i;
                      h < l;
                      h++
                    )
                      for (c = n; c < u; c++)
                        (e = 4 * h * p + 4 * c),
                          (d[e] = r),
                          (d[e + 1] = s),
                          (d[e + 2] = o),
                          (d[e + 3] = a);
              },
              isNeutralState: function () {
                return 1 === this.blocksize;
              },
              getUniformLocations: function (t, e) {
                return {
                  uBlocksize: t.getUniformLocation(e, "uBlocksize"),
                  uStepW: t.getUniformLocation(e, "uStepW"),
                  uStepH: t.getUniformLocation(e, "uStepH"),
                };
              },
              sendUniformData: function (t, e) {
                t.uniform1f(e.uBlocksize, this.blocksize);
              },
            })),
              (e.Image.filters.Pixelate.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.extend,
              n = e.Image.filters,
              r = e.util.createClass;
            (n.RemoveColor = r(n.BaseFilter, {
              type: "RemoveColor",
              color: "#FFFFFF",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\nif(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\ngl_FragColor.a = 0.0;\n}\n}",
              distance: 0.02,
              useAlpha: !1,
              applyTo2d: function (t) {
                var i,
                  n,
                  r,
                  s,
                  o = t.imageData,
                  a = o.data,
                  h = 255 * this.distance,
                  c = new e.Color(this.color).getSource(),
                  l = [c[0] - h, c[1] - h, c[2] - h],
                  u = [c[0] + h, c[1] + h, c[2] + h];
                for (i = 0; i < a.length; i += 4)
                  (n = a[i]),
                    (r = a[i + 1]),
                    (s = a[i + 2]),
                    n > l[0] &&
                      r > l[1] &&
                      s > l[2] &&
                      n < u[0] &&
                      r < u[1] &&
                      s < u[2] &&
                      (a[i + 3] = 0);
              },
              getUniformLocations: function (t, e) {
                return {
                  uLow: t.getUniformLocation(e, "uLow"),
                  uHigh: t.getUniformLocation(e, "uHigh"),
                };
              },
              sendUniformData: function (t, i) {
                var n = new e.Color(this.color).getSource(),
                  r = parseFloat(this.distance),
                  s = [0 + n[0] / 255 - r, 0 + n[1] / 255 - r, 0 + n[2] / 255 - r, 1],
                  o = [n[0] / 255 + r, n[1] / 255 + r, n[2] / 255 + r, 1];
                t.uniform4fv(i.uLow, s), t.uniform4fv(i.uHigh, o);
              },
              toObject: function () {
                return i(this.callSuper("toObject"), {
                  color: this.color,
                  distance: this.distance,
                });
              },
            })),
              (e.Image.filters.RemoveColor.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass,
              r = {
                Brownie: [
                  0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,
                  0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,
                ],
                Vintage: [
                  0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0, 0.02926,
                  0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,
                ],
                Kodachrome: [
                  1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0, 0.09698,
                  -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,
                ],
                Technicolor: [
                  1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0, -0.27589,
                  -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,
                ],
                Polaroid: [
                  1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016, 1.483,
                  0, 0, 0, 0, 0, 1, 0,
                ],
                Sepia: [
                  0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131, 0, 0,
                  0, 0, 0, 1, 0,
                ],
                BlackWhite: [
                  1.5, 1.5, 1.5, 0, -1, 1.5, 1.5, 1.5, 0, -1, 1.5, 1.5, 1.5, 0, -1, 0, 0, 0, 1, 0,
                ],
              };
            for (var s in r)
              (i[s] = n(i.ColorMatrix, {
                type: s,
                matrix: r[s],
                mainParameter: !1,
                colorsOnly: !0,
              })),
                (e.Image.filters[s].fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric,
              i = e.Image.filters,
              n = e.util.createClass;
            (i.BlendColor = n(i.BaseFilter, {
              type: "BlendColor",
              color: "#F95C63",
              mode: "multiply",
              alpha: 1,
              fragmentSource: {
                multiply: "gl_FragColor.rgb *= uColor.rgb;\n",
                screen: "gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",
                add: "gl_FragColor.rgb += uColor.rgb;\n",
                diff: "gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",
                subtract: "gl_FragColor.rgb -= uColor.rgb;\n",
                lighten: "gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",
                darken: "gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",
                exclusion:
                  "gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",
                overlay:
                  "if (uColor.r < 0.5) {\ngl_FragColor.r *= 2.0 * uColor.r;\n} else {\ngl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n}\nif (uColor.g < 0.5) {\ngl_FragColor.g *= 2.0 * uColor.g;\n} else {\ngl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n}\nif (uColor.b < 0.5) {\ngl_FragColor.b *= 2.0 * uColor.b;\n} else {\ngl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n}\n",
                tint: "gl_FragColor.rgb *= (1.0 - uColor.a);\ngl_FragColor.rgb += uColor.rgb;\n",
              },
              buildSource: function (t) {
                return (
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ngl_FragColor = color;\nif (color.a > 0.0) {\n" +
                  this.fragmentSource[t] +
                  "}\n}"
                );
              },
              retrieveShader: function (t) {
                var e,
                  i = this.type + "_" + this.mode;
                return (
                  t.programCache.hasOwnProperty(i) ||
                    ((e = this.buildSource(this.mode)),
                    (t.programCache[i] = this.createProgram(t.context, e))),
                  t.programCache[i]
                );
              },
              applyTo2d: function (t) {
                var i,
                  n,
                  r,
                  s,
                  o,
                  a,
                  h,
                  c = t.imageData,
                  l = c.data,
                  u = l.length,
                  f = 1 - this.alpha;
                (h = new e.Color(this.color).getSource()),
                  (i = h[0] * this.alpha),
                  (n = h[1] * this.alpha),
                  (r = h[2] * this.alpha);
                for (var d = 0; d < u; d += 4)
                  switch (((s = l[d]), (o = l[d + 1]), (a = l[d + 2]), this.mode)) {
                    case "multiply":
                      (l[d] = (s * i) / 255),
                        (l[d + 1] = (o * n) / 255),
                        (l[d + 2] = (a * r) / 255);
                      break;
                    case "screen":
                      (l[d] = 255 - ((255 - s) * (255 - i)) / 255),
                        (l[d + 1] = 255 - ((255 - o) * (255 - n)) / 255),
                        (l[d + 2] = 255 - ((255 - a) * (255 - r)) / 255);
                      break;
                    case "add":
                      (l[d] = s + i), (l[d + 1] = o + n), (l[d + 2] = a + r);
                      break;
                    case "diff":
                    case "difference":
                      (l[d] = Math.abs(s - i)),
                        (l[d + 1] = Math.abs(o - n)),
                        (l[d + 2] = Math.abs(a - r));
                      break;
                    case "subtract":
                      (l[d] = s - i), (l[d + 1] = o - n), (l[d + 2] = a - r);
                      break;
                    case "darken":
                      (l[d] = Math.min(s, i)),
                        (l[d + 1] = Math.min(o, n)),
                        (l[d + 2] = Math.min(a, r));
                      break;
                    case "lighten":
                      (l[d] = Math.max(s, i)),
                        (l[d + 1] = Math.max(o, n)),
                        (l[d + 2] = Math.max(a, r));
                      break;
                    case "overlay":
                      (l[d] =
                        i < 128 ? (2 * s * i) / 255 : 255 - (2 * (255 - s) * (255 - i)) / 255),
                        (l[d + 1] =
                          n < 128 ? (2 * o * n) / 255 : 255 - (2 * (255 - o) * (255 - n)) / 255),
                        (l[d + 2] =
                          r < 128 ? (2 * a * r) / 255 : 255 - (2 * (255 - a) * (255 - r)) / 255);
                      break;
                    case "exclusion":
                      (l[d] = i + s - (2 * i * s) / 255),
                        (l[d + 1] = n + o - (2 * n * o) / 255),
                        (l[d + 2] = r + a - (2 * r * a) / 255);
                      break;
                    case "tint":
                      (l[d] = i + s * f), (l[d + 1] = n + o * f), (l[d + 2] = r + a * f);
                  }
              },
              getUniformLocations: function (t, e) {
                return { uColor: t.getUniformLocation(e, "uColor") };
              },
              sendUniformData: function (t, i) {
                var n = new e.Color(this.color).getSource();
                (n[0] = (this.alpha * n[0]) / 255),
                  (n[1] = (this.alpha * n[1]) / 255),
                  (n[2] = (this.alpha * n[2]) / 255),
                  (n[3] = this.alpha),
                  t.uniform4fv(i.uColor, n);
              },
              toObject: function () {
                return { type: this.type, color: this.color, mode: this.mode, alpha: this.alpha };
              },
            })),
              (e.Image.filters.BlendColor.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric,
              i = e.Image.filters,
              n = e.util.createClass;
            (i.BlendImage = n(i.BaseFilter, {
              type: "BlendImage",
              image: null,
              mode: "multiply",
              alpha: 1,
              vertexSource:
                "attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nuniform mat3 uTransformMatrix;\nvoid main() {\nvTexCoord = aPosition;\nvTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",
              fragmentSource: {
                multiply:
                  "precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.rgba *= color2.rgba;\ngl_FragColor = color;\n}",
                mask: "precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.a = color2.a;\ngl_FragColor = color;\n}",
              },
              retrieveShader: function (t) {
                var e = this.type + "_" + this.mode,
                  i = this.fragmentSource[this.mode];
                return (
                  t.programCache.hasOwnProperty(e) ||
                    (t.programCache[e] = this.createProgram(t.context, i)),
                  t.programCache[e]
                );
              },
              applyToWebGL: function (t) {
                var e = t.context,
                  i = this.createTexture(t.filterBackend, this.image);
                this.bindAdditionalTexture(e, i, e.TEXTURE1),
                  this.callSuper("applyToWebGL", t),
                  this.unbindAdditionalTexture(e, e.TEXTURE1);
              },
              createTexture: function (t, e) {
                return t.getCachedTexture(e.cacheKey, e._element);
              },
              calculateMatrix: function () {
                var t = this.image,
                  e = t._element.width,
                  i = t._element.height;
                return [1 / t.scaleX, 0, 0, 0, 1 / t.scaleY, 0, -t.left / e, -t.top / i, 1];
              },
              applyTo2d: function (t) {
                var i,
                  n,
                  r,
                  s,
                  o,
                  a,
                  h,
                  c,
                  l,
                  u,
                  f,
                  d = t.imageData,
                  g = t.filterBackend.resources,
                  p = d.data,
                  m = p.length,
                  v = d.width,
                  _ = d.height,
                  y = this.image;
                g.blendImage || (g.blendImage = e.util.createCanvasElement()),
                  (l = g.blendImage),
                  (u = l.getContext("2d")),
                  l.width !== v || l.height !== _
                    ? ((l.width = v), (l.height = _))
                    : u.clearRect(0, 0, v, _),
                  u.setTransform(y.scaleX, 0, 0, y.scaleY, y.left, y.top),
                  u.drawImage(y._element, 0, 0, v, _),
                  (f = u.getImageData(0, 0, v, _).data);
                for (var b = 0; b < m; b += 4)
                  switch (
                    ((o = p[b]),
                    (a = p[b + 1]),
                    (h = p[b + 2]),
                    (c = p[b + 3]),
                    (i = f[b]),
                    (n = f[b + 1]),
                    (r = f[b + 2]),
                    (s = f[b + 3]),
                    this.mode)
                  ) {
                    case "multiply":
                      (p[b] = (o * i) / 255),
                        (p[b + 1] = (a * n) / 255),
                        (p[b + 2] = (h * r) / 255),
                        (p[b + 3] = (c * s) / 255);
                      break;
                    case "mask":
                      p[b + 3] = s;
                      break;
                  }
              },
              getUniformLocations: function (t, e) {
                return {
                  uTransformMatrix: t.getUniformLocation(e, "uTransformMatrix"),
                  uImage: t.getUniformLocation(e, "uImage"),
                };
              },
              sendUniformData: function (t, e) {
                var i = this.calculateMatrix();
                t.uniform1i(e.uImage, 1), t.uniformMatrix3fv(e.uTransformMatrix, !1, i);
              },
              toObject: function () {
                return {
                  type: this.type,
                  image: this.image && this.image.toObject(),
                  mode: this.mode,
                  alpha: this.alpha,
                };
              },
            })),
              (e.Image.filters.BlendImage.fromObject = function (t, i) {
                e.Image.fromObject(t.image, function (n) {
                  var r = e.util.object.clone(t);
                  (r.image = n), i(new e.Image.filters.BlendImage(r));
                });
              });
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = Math.pow,
              n = Math.floor,
              r = Math.sqrt,
              s = Math.abs,
              o = Math.round,
              a = Math.sin,
              h = Math.ceil,
              c = e.Image.filters,
              l = e.util.createClass;
            (c.Resize = l(c.BaseFilter, {
              type: "Resize",
              resizeType: "hermite",
              scaleX: 1,
              scaleY: 1,
              lanczosLobes: 3,
              getUniformLocations: function (t, e) {
                return {
                  uDelta: t.getUniformLocation(e, "uDelta"),
                  uTaps: t.getUniformLocation(e, "uTaps"),
                };
              },
              sendUniformData: function (t, e) {
                t.uniform2fv(
                  e.uDelta,
                  this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height]
                ),
                  t.uniform1fv(e.uTaps, this.taps);
              },
              retrieveShader: function (t) {
                var e = this.getFilterWindow(),
                  i = this.type + "_" + e;
                if (!t.programCache.hasOwnProperty(i)) {
                  var n = this.generateShader(e);
                  t.programCache[i] = this.createProgram(t.context, n);
                }
                return t.programCache[i];
              },
              getFilterWindow: function () {
                var t = this.tempScale;
                return Math.ceil(this.lanczosLobes / t);
              },
              getTaps: function () {
                for (
                  var t = this.lanczosCreate(this.lanczosLobes),
                    e = this.tempScale,
                    i = this.getFilterWindow(),
                    n = new Array(i),
                    r = 1;
                  r <= i;
                  r++
                )
                  n[r - 1] = t(r * e);
                return n;
              },
              generateShader: function (t) {
                for (var e = new Array(t), i = this.fragmentSourceTOP, n = 1; n <= t; n++)
                  e[n - 1] = n + ".0 * uDelta";
                return (
                  (i += "uniform float uTaps[" + t + "];\n"),
                  (i += "void main() {\n"),
                  (i += "  vec4 color = texture2D(uTexture, vTexCoord);\n"),
                  (i += "  float sum = 1.0;\n"),
                  e.forEach(function (t, e) {
                    (i +=
                      "  color += texture2D(uTexture, vTexCoord + " +
                      t +
                      ") * uTaps[" +
                      e +
                      "];\n"),
                      (i +=
                        "  color += texture2D(uTexture, vTexCoord - " +
                        t +
                        ") * uTaps[" +
                        e +
                        "];\n"),
                      (i += "  sum += 2.0 * uTaps[" + e + "];\n");
                  }),
                  (i += "  gl_FragColor = color / sum;\n"),
                  (i += "}"),
                  i
                );
              },
              fragmentSourceTOP:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\n",
              applyTo: function (t) {
                t.webgl
                  ? (t.passes++,
                    (this.width = t.sourceWidth),
                    (this.horizontal = !0),
                    (this.dW = Math.round(this.width * this.scaleX)),
                    (this.dH = t.sourceHeight),
                    (this.tempScale = this.dW / this.width),
                    (this.taps = this.getTaps()),
                    (t.destinationWidth = this.dW),
                    this._setupFrameBuffer(t),
                    this.applyToWebGL(t),
                    this._swapTextures(t),
                    (t.sourceWidth = t.destinationWidth),
                    (this.height = t.sourceHeight),
                    (this.horizontal = !1),
                    (this.dH = Math.round(this.height * this.scaleY)),
                    (this.tempScale = this.dH / this.height),
                    (this.taps = this.getTaps()),
                    (t.destinationHeight = this.dH),
                    this._setupFrameBuffer(t),
                    this.applyToWebGL(t),
                    this._swapTextures(t),
                    (t.sourceHeight = t.destinationHeight))
                  : this.applyTo2d(t);
              },
              isNeutralState: function () {
                return 1 === this.scaleX && 1 === this.scaleY;
              },
              lanczosCreate: function (t) {
                return function (e) {
                  if (e >= t || e <= -t) return 0;
                  if (e < 1.1920929e-7 && e > -1.1920929e-7) return 1;
                  e *= Math.PI;
                  var i = e / t;
                  return ((a(e) / e) * a(i)) / i;
                };
              },
              applyTo2d: function (t) {
                var e = t.imageData,
                  i = this.scaleX,
                  n = this.scaleY;
                (this.rcpScaleX = 1 / i), (this.rcpScaleY = 1 / n);
                var r,
                  s = e.width,
                  a = e.height,
                  h = o(s * i),
                  c = o(a * n);
                "sliceHack" === this.resizeType
                  ? (r = this.sliceByTwo(t, s, a, h, c))
                  : "hermite" === this.resizeType
                  ? (r = this.hermiteFastResize(t, s, a, h, c))
                  : "bilinear" === this.resizeType
                  ? (r = this.bilinearFiltering(t, s, a, h, c))
                  : "lanczos" === this.resizeType && (r = this.lanczosResize(t, s, a, h, c)),
                  (t.imageData = r);
              },
              sliceByTwo: function (t, i, r, s, o) {
                var a,
                  h,
                  c = t.imageData,
                  l = 0.5,
                  u = !1,
                  f = !1,
                  d = i * l,
                  g = r * l,
                  p = e.filterBackend.resources,
                  m = 0,
                  v = 0,
                  _ = i,
                  y = 0;
                p.sliceByTwo || (p.sliceByTwo = document.createElement("canvas")),
                  (a = p.sliceByTwo),
                  (a.width < 1.5 * i || a.height < r) && ((a.width = 1.5 * i), (a.height = r)),
                  (h = a.getContext("2d")),
                  h.clearRect(0, 0, 1.5 * i, r),
                  h.putImageData(c, 0, 0),
                  (s = n(s)),
                  (o = n(o));
                while (!u || !f)
                  (i = d),
                    (r = g),
                    s < n(d * l) ? (d = n(d * l)) : ((d = s), (u = !0)),
                    o < n(g * l) ? (g = n(g * l)) : ((g = o), (f = !0)),
                    h.drawImage(a, m, v, i, r, _, y, d, g),
                    (m = _),
                    (v = y),
                    (y += g);
                return h.getImageData(m, v, s, o);
              },
              lanczosResize: function (t, e, o, a, c) {
                function l(t) {
                  var h, S, T, O, k, E, P, D, j, A, M;
                  for (C.x = (t + 0.5) * p, w.x = n(C.x), h = 0; h < c; h++) {
                    for (
                      C.y = (h + 0.5) * m,
                        w.y = n(C.y),
                        k = 0,
                        E = 0,
                        P = 0,
                        D = 0,
                        j = 0,
                        S = w.x - y;
                      S <= w.x + y;
                      S++
                    )
                      if (!(S < 0 || S >= e)) {
                        (A = n(1e3 * s(S - C.x))), x[A] || (x[A] = {});
                        for (var I = w.y - b; I <= w.y + b; I++)
                          I < 0 ||
                            I >= o ||
                            ((M = n(1e3 * s(I - C.y))),
                            x[A][M] || (x[A][M] = g(r(i(A * v, 2) + i(M * _, 2)) / 1e3)),
                            (T = x[A][M]),
                            T > 0 &&
                              ((O = 4 * (I * e + S)),
                              (k += T),
                              (E += T * u[O]),
                              (P += T * u[O + 1]),
                              (D += T * u[O + 2]),
                              (j += T * u[O + 3])));
                      }
                    (O = 4 * (h * a + t)),
                      (d[O] = E / k),
                      (d[O + 1] = P / k),
                      (d[O + 2] = D / k),
                      (d[O + 3] = j / k);
                  }
                  return ++t < a ? l(t) : f;
                }
                var u = t.imageData.data,
                  f = t.ctx.createImageData(a, c),
                  d = f.data,
                  g = this.lanczosCreate(this.lanczosLobes),
                  p = this.rcpScaleX,
                  m = this.rcpScaleY,
                  v = 2 / this.rcpScaleX,
                  _ = 2 / this.rcpScaleY,
                  y = h((p * this.lanczosLobes) / 2),
                  b = h((m * this.lanczosLobes) / 2),
                  x = {},
                  C = {},
                  w = {};
                return l(0);
              },
              bilinearFiltering: function (t, e, i, r, s) {
                var o,
                  a,
                  h,
                  c,
                  l,
                  u,
                  f,
                  d,
                  g,
                  p,
                  m,
                  v,
                  _,
                  y = 0,
                  b = this.rcpScaleX,
                  x = this.rcpScaleY,
                  C = 4 * (e - 1),
                  w = t.imageData,
                  S = w.data,
                  T = t.ctx.createImageData(r, s),
                  O = T.data;
                for (f = 0; f < s; f++)
                  for (d = 0; d < r; d++)
                    for (
                      l = n(b * d),
                        u = n(x * f),
                        g = b * d - l,
                        p = x * f - u,
                        _ = 4 * (u * e + l),
                        m = 0;
                      m < 4;
                      m++
                    )
                      (o = S[_ + m]),
                        (a = S[_ + 4 + m]),
                        (h = S[_ + C + m]),
                        (c = S[_ + C + 4 + m]),
                        (v = o * (1 - g) * (1 - p) + a * g * (1 - p) + h * p * (1 - g) + c * g * p),
                        (O[y++] = v);
                return T;
              },
              hermiteFastResize: function (t, e, i, o, a) {
                for (
                  var c = this.rcpScaleX,
                    l = this.rcpScaleY,
                    u = h(c / 2),
                    f = h(l / 2),
                    d = t.imageData,
                    g = d.data,
                    p = t.ctx.createImageData(o, a),
                    m = p.data,
                    v = 0;
                  v < a;
                  v++
                )
                  for (var _ = 0; _ < o; _++) {
                    for (
                      var y = 4 * (_ + v * o),
                        b = 0,
                        x = 0,
                        C = 0,
                        w = 0,
                        S = 0,
                        T = 0,
                        O = 0,
                        k = (v + 0.5) * l,
                        E = n(v * l);
                      E < (v + 1) * l;
                      E++
                    )
                      for (
                        var P = s(k - (E + 0.5)) / f, D = (_ + 0.5) * c, j = P * P, A = n(_ * c);
                        A < (_ + 1) * c;
                        A++
                      ) {
                        var M = s(D - (A + 0.5)) / u,
                          I = r(j + M * M);
                        (I > 1 && I < -1) ||
                          ((b = 2 * I * I * I - 3 * I * I + 1),
                          b > 0 &&
                            ((M = 4 * (A + E * e)),
                            (O += b * g[M + 3]),
                            (C += b),
                            g[M + 3] < 255 && (b = (b * g[M + 3]) / 250),
                            (w += b * g[M]),
                            (S += b * g[M + 1]),
                            (T += b * g[M + 2]),
                            (x += b)));
                      }
                    (m[y] = w / x), (m[y + 1] = S / x), (m[y + 2] = T / x), (m[y + 3] = O / C);
                  }
                return p;
              },
              toObject: function () {
                return {
                  type: this.type,
                  scaleX: this.scaleX,
                  scaleY: this.scaleY,
                  resizeType: this.resizeType,
                  lanczosLobes: this.lanczosLobes,
                };
              },
            })),
              (e.Image.filters.Resize.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Contrast = n(i.BaseFilter, {
              type: "Contrast",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",
              contrast: 0,
              mainParameter: "contrast",
              applyTo2d: function (t) {
                if (0 !== this.contrast) {
                  var e,
                    i = t.imageData,
                    n = i.data,
                    r = n.length,
                    s = Math.floor(255 * this.contrast),
                    o = (259 * (s + 255)) / (255 * (259 - s));
                  for (e = 0; e < r; e += 4)
                    (n[e] = o * (n[e] - 128) + 128),
                      (n[e + 1] = o * (n[e + 1] - 128) + 128),
                      (n[e + 2] = o * (n[e + 2] - 128) + 128);
                }
              },
              getUniformLocations: function (t, e) {
                return { uContrast: t.getUniformLocation(e, "uContrast") };
              },
              sendUniformData: function (t, e) {
                t.uniform1f(e.uContrast, this.contrast);
              },
            })),
              (e.Image.filters.Contrast.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Saturation = n(i.BaseFilter, {
              type: "Saturation",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform float uSaturation;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat rgMax = max(color.r, color.g);\nfloat rgbMax = max(rgMax, color.b);\ncolor.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\ncolor.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\ncolor.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\ngl_FragColor = color;\n}",
              saturation: 0,
              mainParameter: "saturation",
              applyTo2d: function (t) {
                if (0 !== this.saturation) {
                  var e,
                    i,
                    n = t.imageData,
                    r = n.data,
                    s = r.length,
                    o = -this.saturation;
                  for (e = 0; e < s; e += 4)
                    (i = Math.max(r[e], r[e + 1], r[e + 2])),
                      (r[e] += i !== r[e] ? (i - r[e]) * o : 0),
                      (r[e + 1] += i !== r[e + 1] ? (i - r[e + 1]) * o : 0),
                      (r[e + 2] += i !== r[e + 2] ? (i - r[e + 2]) * o : 0);
                }
              },
              getUniformLocations: function (t, e) {
                return { uSaturation: t.getUniformLocation(e, "uSaturation") };
              },
              sendUniformData: function (t, e) {
                t.uniform1f(e.uSaturation, -this.saturation);
              },
            })),
              (e.Image.filters.Saturation.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Blur = n(i.BaseFilter, {
              type: "Blur",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\nconst float nSamples = 15.0;\nvec3 v3offset = vec3(12.9898, 78.233, 151.7182);\nfloat random(vec3 scale) {\nreturn fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n}\nvoid main() {\nvec4 color = vec4(0.0);\nfloat total = 0.0;\nfloat offset = random(v3offset);\nfor (float t = -nSamples; t <= nSamples; t++) {\nfloat percent = (t + offset - 0.5) / nSamples;\nfloat weight = 1.0 - abs(percent);\ncolor += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\ntotal += weight;\n}\ngl_FragColor = color / total;\n}",
              blur: 0,
              mainParameter: "blur",
              applyTo: function (t) {
                t.webgl
                  ? ((this.aspectRatio = t.sourceWidth / t.sourceHeight),
                    t.passes++,
                    this._setupFrameBuffer(t),
                    (this.horizontal = !0),
                    this.applyToWebGL(t),
                    this._swapTextures(t),
                    this._setupFrameBuffer(t),
                    (this.horizontal = !1),
                    this.applyToWebGL(t),
                    this._swapTextures(t))
                  : this.applyTo2d(t);
              },
              applyTo2d: function (t) {
                t.imageData = this.simpleBlur(t);
              },
              simpleBlur: function (t) {
                var i,
                  n,
                  r = t.filterBackend.resources,
                  s = t.imageData.width,
                  o = t.imageData.height;
                r.blurLayer1 ||
                  ((r.blurLayer1 = e.util.createCanvasElement()),
                  (r.blurLayer2 = e.util.createCanvasElement())),
                  (i = r.blurLayer1),
                  (n = r.blurLayer2),
                  (i.width === s && i.height === o) ||
                    ((n.width = i.width = s), (n.height = i.height = o));
                var a,
                  h,
                  c,
                  l,
                  u = i.getContext("2d"),
                  f = n.getContext("2d"),
                  d = 15,
                  g = 0.06 * this.blur * 0.5;
                for (
                  u.putImageData(t.imageData, 0, 0), f.clearRect(0, 0, s, o), l = -d;
                  l <= d;
                  l++
                )
                  (a = (Math.random() - 0.5) / 4),
                    (h = l / d),
                    (c = g * h * s + a),
                    (f.globalAlpha = 1 - Math.abs(h)),
                    f.drawImage(i, c, a),
                    u.drawImage(n, 0, 0),
                    (f.globalAlpha = 1),
                    f.clearRect(0, 0, n.width, n.height);
                for (l = -d; l <= d; l++)
                  (a = (Math.random() - 0.5) / 4),
                    (h = l / d),
                    (c = g * h * o + a),
                    (f.globalAlpha = 1 - Math.abs(h)),
                    f.drawImage(i, a, c),
                    u.drawImage(n, 0, 0),
                    (f.globalAlpha = 1),
                    f.clearRect(0, 0, n.width, n.height);
                t.ctx.drawImage(i, 0, 0);
                var p = t.ctx.getImageData(0, 0, i.width, i.height);
                return (u.globalAlpha = 1), u.clearRect(0, 0, i.width, i.height), p;
              },
              getUniformLocations: function (t, e) {
                return { delta: t.getUniformLocation(e, "uDelta") };
              },
              sendUniformData: function (t, e) {
                var i = this.chooseRightDelta();
                t.uniform2fv(e.delta, i);
              },
              chooseRightDelta: function () {
                var t,
                  e = 1,
                  i = [0, 0];
                return (
                  this.horizontal
                    ? this.aspectRatio > 1 && (e = 1 / this.aspectRatio)
                    : this.aspectRatio < 1 && (e = this.aspectRatio),
                  (t = e * this.blur * 0.12),
                  this.horizontal ? (i[0] = t) : (i[1] = t),
                  i
                );
              },
            })),
              (i.Blur.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Gamma = n(i.BaseFilter, {
              type: "Gamma",
              fragmentSource:
                "precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",
              gamma: [1, 1, 1],
              mainParameter: "gamma",
              initialize: function (t) {
                (this.gamma = [1, 1, 1]), i.BaseFilter.prototype.initialize.call(this, t);
              },
              applyTo2d: function (t) {
                var e,
                  i = t.imageData,
                  n = i.data,
                  r = this.gamma,
                  s = n.length,
                  o = 1 / r[0],
                  a = 1 / r[1],
                  h = 1 / r[2];
                for (
                  this.rVals ||
                    ((this.rVals = new Uint8Array(256)),
                    (this.gVals = new Uint8Array(256)),
                    (this.bVals = new Uint8Array(256))),
                    e = 0,
                    s = 256;
                  e < s;
                  e++
                )
                  (this.rVals[e] = 255 * Math.pow(e / 255, o)),
                    (this.gVals[e] = 255 * Math.pow(e / 255, a)),
                    (this.bVals[e] = 255 * Math.pow(e / 255, h));
                for (e = 0, s = n.length; e < s; e += 4)
                  (n[e] = this.rVals[n[e]]),
                    (n[e + 1] = this.gVals[n[e + 1]]),
                    (n[e + 2] = this.bVals[n[e + 2]]);
              },
              getUniformLocations: function (t, e) {
                return { uGamma: t.getUniformLocation(e, "uGamma") };
              },
              sendUniformData: function (t, e) {
                t.uniform3fv(e.uGamma, this.gamma);
              },
            })),
              (e.Image.filters.Gamma.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.Composed = n(i.BaseFilter, {
              type: "Composed",
              subFilters: [],
              initialize: function (t) {
                this.callSuper("initialize", t), (this.subFilters = this.subFilters.slice(0));
              },
              applyTo: function (t) {
                (t.passes += this.subFilters.length - 1),
                  this.subFilters.forEach(function (e) {
                    e.applyTo(t);
                  });
              },
              toObject: function () {
                return e.util.object.extend(this.callSuper("toObject"), {
                  subFilters: this.subFilters.map(function (t) {
                    return t.toObject();
                  }),
                });
              },
              isNeutralState: function () {
                return !this.subFilters.some(function (t) {
                  return !t.isNeutralState();
                });
              },
            })),
              (e.Image.filters.Composed.fromObject = function (t, i) {
                var n = t.subFilters || [],
                  r = n.map(function (t) {
                    return new e.Image.filters[t.type](t);
                  }),
                  s = new e.Image.filters.Composed({ subFilters: r });
                return i && i(s), s;
              });
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.Image.filters,
              n = e.util.createClass;
            (i.HueRotation = n(i.ColorMatrix, {
              type: "HueRotation",
              rotation: 0,
              mainParameter: "rotation",
              calculateMatrix: function () {
                var t = this.rotation * Math.PI,
                  i = e.util.cos(t),
                  n = e.util.sin(t),
                  r = 1 / 3,
                  s = Math.sqrt(r) * n,
                  o = 1 - i;
                (this.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]),
                  (this.matrix[0] = i + o / 3),
                  (this.matrix[1] = r * o - s),
                  (this.matrix[2] = r * o + s),
                  (this.matrix[5] = r * o + s),
                  (this.matrix[6] = i + r * o),
                  (this.matrix[7] = r * o - s),
                  (this.matrix[10] = r * o - s),
                  (this.matrix[11] = r * o + s),
                  (this.matrix[12] = i + r * o);
              },
              isNeutralState: function (t) {
                return this.calculateMatrix(), i.BaseFilter.prototype.isNeutralState.call(this, t);
              },
              applyTo: function (t) {
                this.calculateMatrix(), i.BaseFilter.prototype.applyTo.call(this, t);
              },
            })),
              (e.Image.filters.HueRotation.fromObject = e.Image.filters.BaseFilter.fromObject);
          })(e),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {}),
              i = e.util.object.clone;
            e.Text
              ? e.warn("fabric.Text is already defined")
              : ((e.Text = e.util.createClass(e.Object, {
                  _dimensionAffectingProps: [
                    "fontSize",
                    "fontWeight",
                    "fontFamily",
                    "fontStyle",
                    "lineHeight",
                    "text",
                    "charSpacing",
                    "textAlign",
                    "styles",
                  ],
                  _reNewline: /\r?\n/,
                  _reSpacesAndTabs: /[ \t\r]/g,
                  _reSpaceAndTab: /[ \t\r]/,
                  _reWords: /\S+/g,
                  type: "text",
                  fontSize: 40,
                  fontWeight: "normal",
                  fontFamily: "Times New Roman",
                  underline: !1,
                  overline: !1,
                  linethrough: !1,
                  textAlign: "left",
                  fontStyle: "normal",
                  lineHeight: 1.16,
                  superscript: { size: 0.6, baseline: -0.35 },
                  subscript: { size: 0.6, baseline: 0.11 },
                  textBackgroundColor: "",
                  stateProperties: e.Object.prototype.stateProperties.concat(
                    "fontFamily",
                    "fontWeight",
                    "fontSize",
                    "text",
                    "underline",
                    "overline",
                    "linethrough",
                    "textAlign",
                    "fontStyle",
                    "lineHeight",
                    "textBackgroundColor",
                    "charSpacing",
                    "styles"
                  ),
                  cacheProperties: e.Object.prototype.cacheProperties.concat(
                    "fontFamily",
                    "fontWeight",
                    "fontSize",
                    "text",
                    "underline",
                    "overline",
                    "linethrough",
                    "textAlign",
                    "fontStyle",
                    "lineHeight",
                    "textBackgroundColor",
                    "charSpacing",
                    "styles"
                  ),
                  stroke: null,
                  shadow: null,
                  _fontSizeFraction: 0.222,
                  offsets: { underline: 0.1, linethrough: -0.315, overline: -0.88 },
                  _fontSizeMult: 1.13,
                  charSpacing: 0,
                  styles: null,
                  _measuringContext: null,
                  deltaY: 0,
                  _styleProperties: [
                    "stroke",
                    "strokeWidth",
                    "fill",
                    "fontFamily",
                    "fontSize",
                    "fontWeight",
                    "fontStyle",
                    "underline",
                    "overline",
                    "linethrough",
                    "deltaY",
                    "textBackgroundColor",
                  ],
                  __charBounds: [],
                  CACHE_FONT_SIZE: 400,
                  MIN_TEXT_WIDTH: 2,
                  initialize: function (t, e) {
                    (this.styles = (e && e.styles) || {}),
                      (this.text = t),
                      (this.__skipDimension = !0),
                      this.callSuper("initialize", e),
                      (this.__skipDimension = !1),
                      this.initDimensions(),
                      this.setCoords(),
                      this.setupState({ propertySet: "_dimensionAffectingProps" });
                  },
                  getMeasuringContext: function () {
                    return (
                      e._measuringContext ||
                        (e._measuringContext =
                          (this.canvas && this.canvas.contextCache) ||
                          e.util.createCanvasElement().getContext("2d")),
                      e._measuringContext
                    );
                  },
                  _splitText: function () {
                    var t = this._splitTextIntoLines(this.text);
                    return (
                      (this.textLines = t.lines),
                      (this._textLines = t.graphemeLines),
                      (this._unwrappedTextLines = t._unwrappedLines),
                      (this._text = t.graphemeText),
                      t
                    );
                  },
                  initDimensions: function () {
                    this.__skipDimension ||
                      (this._splitText(),
                      this._clearCache(),
                      (this.width =
                        this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH),
                      -1 !== this.textAlign.indexOf("justify") && this.enlargeSpaces(),
                      (this.height = this.calcTextHeight()),
                      this.saveState({ propertySet: "_dimensionAffectingProps" }));
                  },
                  enlargeSpaces: function () {
                    for (var t, e, i, n, r, s, o, a = 0, h = this._textLines.length; a < h; a++)
                      if (
                        ("justify" === this.textAlign ||
                          (a !== h - 1 && !this.isEndOfWrapping(a))) &&
                        ((n = 0),
                        (r = this._textLines[a]),
                        (e = this.getLineWidth(a)),
                        e < this.width && (o = this.textLines[a].match(this._reSpacesAndTabs)))
                      ) {
                        (i = o.length), (t = (this.width - e) / i);
                        for (var c = 0, l = r.length; c <= l; c++)
                          (s = this.__charBounds[a][c]),
                            this._reSpaceAndTab.test(r[c])
                              ? ((s.width += t), (s.kernedWidth += t), (s.left += n), (n += t))
                              : (s.left += n);
                      }
                  },
                  isEndOfWrapping: function (t) {
                    return t === this._textLines.length - 1;
                  },
                  toString: function () {
                    return (
                      "#<fabric.Text (" +
                      this.complexity() +
                      '): { "text": "' +
                      this.text +
                      '", "fontFamily": "' +
                      this.fontFamily +
                      '" }>'
                    );
                  },
                  _getCacheCanvasDimensions: function () {
                    var t = this.callSuper("_getCacheCanvasDimensions"),
                      e = this.fontSize;
                    return (t.width += e * t.zoomX), (t.height += e * t.zoomY), t;
                  },
                  _render: function (t) {
                    this._setTextStyles(t),
                      this._renderTextLinesBackground(t),
                      this._renderTextDecoration(t, "underline"),
                      this._renderText(t),
                      this._renderTextDecoration(t, "overline"),
                      this._renderTextDecoration(t, "linethrough");
                  },
                  _renderText: function (t) {
                    "stroke" === this.paintFirst
                      ? (this._renderTextStroke(t), this._renderTextFill(t))
                      : (this._renderTextFill(t), this._renderTextStroke(t));
                  },
                  _setTextStyles: function (t, e, i) {
                    (t.textBaseline = "alphabetic"), (t.font = this._getFontDeclaration(e, i));
                  },
                  calcTextWidth: function () {
                    for (
                      var t = this.getLineWidth(0), e = 1, i = this._textLines.length;
                      e < i;
                      e++
                    ) {
                      var n = this.getLineWidth(e);
                      n > t && (t = n);
                    }
                    return t;
                  },
                  _renderTextLine: function (t, e, i, n, r, s) {
                    this._renderChars(t, e, i, n, r, s);
                  },
                  _renderTextLinesBackground: function (t) {
                    if (this.textBackgroundColor || this.styleHas("textBackgroundColor")) {
                      for (
                        var e,
                          i,
                          n,
                          r,
                          s,
                          o,
                          a = 0,
                          h = t.fillStyle,
                          c = this._getLeftOffset(),
                          l = this._getTopOffset(),
                          u = 0,
                          f = 0,
                          d = 0,
                          g = this._textLines.length;
                        d < g;
                        d++
                      )
                        if (
                          ((e = this.getHeightOfLine(d)),
                          this.textBackgroundColor || this.styleHas("textBackgroundColor", d))
                        ) {
                          (n = this._textLines[d]),
                            (i = this._getLineLeftOffset(d)),
                            (f = 0),
                            (u = 0),
                            (r = this.getValueOfPropertyAt(d, 0, "textBackgroundColor"));
                          for (var p = 0, m = n.length; p < m; p++)
                            (s = this.__charBounds[d][p]),
                              (o = this.getValueOfPropertyAt(d, p, "textBackgroundColor")),
                              o !== r
                                ? ((t.fillStyle = r),
                                  r && t.fillRect(c + i + u, l + a, f, e / this.lineHeight),
                                  (u = s.left),
                                  (f = s.width),
                                  (r = o))
                                : (f += s.kernedWidth);
                          o &&
                            ((t.fillStyle = o),
                            t.fillRect(c + i + u, l + a, f, e / this.lineHeight)),
                            (a += e);
                        } else a += e;
                      (t.fillStyle = h), this._removeShadow(t);
                    }
                  },
                  getFontCache: function (t) {
                    var i = t.fontFamily.toLowerCase();
                    e.charWidthsCache[i] || (e.charWidthsCache[i] = {});
                    var n = e.charWidthsCache[i],
                      r = t.fontStyle.toLowerCase() + "_" + (t.fontWeight + "").toLowerCase();
                    return n[r] || (n[r] = {}), n[r];
                  },
                  _applyCharStyles: function (t, e, i, n, r) {
                    this._setFillStyles(e, r),
                      this._setStrokeStyles(e, r),
                      (e.font = this._getFontDeclaration(r));
                  },
                  _measureChar: function (t, e, i, n) {
                    var r,
                      s,
                      o,
                      a,
                      h = this.getFontCache(e),
                      c = this._getFontDeclaration(e),
                      l = this._getFontDeclaration(n),
                      u = i + t,
                      f = c === l,
                      d = e.fontSize / this.CACHE_FONT_SIZE;
                    if (
                      (i && void 0 !== h[i] && (o = h[i]),
                      void 0 !== h[t] && (a = r = h[t]),
                      f && void 0 !== h[u] && ((s = h[u]), (a = s - o)),
                      void 0 === r || void 0 === o || void 0 === s)
                    ) {
                      var g = this.getMeasuringContext();
                      this._setTextStyles(g, e, !0);
                    }
                    return (
                      void 0 === r && ((a = r = g.measureText(t).width), (h[t] = r)),
                      void 0 === o && f && i && ((o = g.measureText(i).width), (h[i] = o)),
                      f && void 0 === s && ((s = g.measureText(u).width), (h[u] = s), (a = s - o)),
                      { width: r * d, kernedWidth: a * d }
                    );
                  },
                  getHeightOfChar: function (t, e) {
                    return this.getValueOfPropertyAt(t, e, "fontSize");
                  },
                  measureLine: function (t) {
                    var e = this._measureLine(t);
                    return (
                      0 !== this.charSpacing && (e.width -= this._getWidthOfCharSpacing()),
                      e.width < 0 && (e.width = 0),
                      e
                    );
                  },
                  _measureLine: function (t) {
                    var e,
                      i,
                      n,
                      r,
                      s = 0,
                      o = this._textLines[t],
                      a = 0,
                      h = new Array(o.length);
                    for (this.__charBounds[t] = h, e = 0; e < o.length; e++)
                      (i = o[e]),
                        (r = this._getGraphemeBox(i, t, e, n)),
                        (h[e] = r),
                        (s += r.kernedWidth),
                        (n = i);
                    return (
                      (h[e] = {
                        left: r ? r.left + r.width : 0,
                        width: 0,
                        kernedWidth: 0,
                        height: this.fontSize,
                      }),
                      { width: s, numOfSpaces: a }
                    );
                  },
                  _getGraphemeBox: function (t, e, i, n, r) {
                    var s,
                      o = this.getCompleteStyleDeclaration(e, i),
                      a = n ? this.getCompleteStyleDeclaration(e, i - 1) : {},
                      h = this._measureChar(t, o, n, a),
                      c = h.kernedWidth,
                      l = h.width;
                    0 !== this.charSpacing &&
                      ((s = this._getWidthOfCharSpacing()), (l += s), (c += s));
                    var u = {
                      width: l,
                      left: 0,
                      height: o.fontSize,
                      kernedWidth: c,
                      deltaY: o.deltaY,
                    };
                    if (i > 0 && !r) {
                      var f = this.__charBounds[e][i - 1];
                      u.left = f.left + f.width + h.kernedWidth - h.width;
                    }
                    return u;
                  },
                  getHeightOfLine: function (t) {
                    if (this.__lineHeights[t]) return this.__lineHeights[t];
                    for (
                      var e = this._textLines[t],
                        i = this.getHeightOfChar(t, 0),
                        n = 1,
                        r = e.length;
                      n < r;
                      n++
                    )
                      i = Math.max(this.getHeightOfChar(t, n), i);
                    return (this.__lineHeights[t] = i * this.lineHeight * this._fontSizeMult);
                  },
                  calcTextHeight: function () {
                    for (var t, e = 0, i = 0, n = this._textLines.length; i < n; i++)
                      (t = this.getHeightOfLine(i)), (e += i === n - 1 ? t / this.lineHeight : t);
                    return e;
                  },
                  _getLeftOffset: function () {
                    return -this.width / 2;
                  },
                  _getTopOffset: function () {
                    return -this.height / 2;
                  },
                  _renderTextCommon: function (t, e) {
                    t.save();
                    for (
                      var i = 0,
                        n = this._getLeftOffset(),
                        r = this._getTopOffset(),
                        s = this._applyPatternGradientTransform(
                          t,
                          "fillText" === e ? this.fill : this.stroke
                        ),
                        o = 0,
                        a = this._textLines.length;
                      o < a;
                      o++
                    ) {
                      var h = this.getHeightOfLine(o),
                        c = h / this.lineHeight,
                        l = this._getLineLeftOffset(o);
                      this._renderTextLine(
                        e,
                        t,
                        this._textLines[o],
                        n + l - s.offsetX,
                        r + i + c - s.offsetY,
                        o
                      ),
                        (i += h);
                    }
                    t.restore();
                  },
                  _renderTextFill: function (t) {
                    (this.fill || this.styleHas("fill")) && this._renderTextCommon(t, "fillText");
                  },
                  _renderTextStroke: function (t) {
                    ((this.stroke && 0 !== this.strokeWidth) || !this.isEmptyStyles()) &&
                      (this.shadow && !this.shadow.affectStroke && this._removeShadow(t),
                      t.save(),
                      this._setLineDash(t, this.strokeDashArray),
                      t.beginPath(),
                      this._renderTextCommon(t, "strokeText"),
                      t.closePath(),
                      t.restore());
                  },
                  _renderChars: function (t, e, i, n, r, s) {
                    var o,
                      a,
                      h,
                      c,
                      l = this.getHeightOfLine(s),
                      u = -1 !== this.textAlign.indexOf("justify"),
                      f = "",
                      d = 0,
                      g = !u && 0 === this.charSpacing && this.isEmptyStyles(s);
                    if ((e.save(), (r -= (l * this._fontSizeFraction) / this.lineHeight), g))
                      return (
                        this._renderChar(t, e, s, 0, this.textLines[s], n, r, l), void e.restore()
                      );
                    for (var p = 0, m = i.length - 1; p <= m; p++)
                      (c = p === m || this.charSpacing),
                        (f += i[p]),
                        (h = this.__charBounds[s][p]),
                        0 === d
                          ? ((n += h.kernedWidth - h.width), (d += h.width))
                          : (d += h.kernedWidth),
                        u && !c && this._reSpaceAndTab.test(i[p]) && (c = !0),
                        c ||
                          ((o = o || this.getCompleteStyleDeclaration(s, p)),
                          (a = this.getCompleteStyleDeclaration(s, p + 1)),
                          (c = this._hasStyleChanged(o, a))),
                        c &&
                          (this._renderChar(t, e, s, p, f, n, r, l),
                          (f = ""),
                          (o = a),
                          (n += d),
                          (d = 0));
                    e.restore();
                  },
                  _renderChar: function (t, e, i, n, r, s, o) {
                    var a = this._getStyleDeclaration(i, n),
                      h = this.getCompleteStyleDeclaration(i, n),
                      c = "fillText" === t && h.fill,
                      l = "strokeText" === t && h.stroke && h.strokeWidth;
                    (l || c) &&
                      (a && e.save(),
                      this._applyCharStyles(t, e, i, n, h),
                      a && a.textBackgroundColor && this._removeShadow(e),
                      a && a.deltaY && (o += a.deltaY),
                      c && e.fillText(r, s, o),
                      l && e.strokeText(r, s, o),
                      a && e.restore());
                  },
                  setSuperscript: function (t, e) {
                    return this._setScript(t, e, this.superscript);
                  },
                  setSubscript: function (t, e) {
                    return this._setScript(t, e, this.subscript);
                  },
                  _setScript: function (t, e, i) {
                    var n = this.get2DCursorLocation(t, !0),
                      r = this.getValueOfPropertyAt(n.lineIndex, n.charIndex, "fontSize"),
                      s = this.getValueOfPropertyAt(n.lineIndex, n.charIndex, "deltaY"),
                      o = { fontSize: r * i.size, deltaY: s + r * i.baseline };
                    return this.setSelectionStyles(o, t, e), this;
                  },
                  _hasStyleChanged: function (t, e) {
                    return (
                      t.fill !== e.fill ||
                      t.stroke !== e.stroke ||
                      t.strokeWidth !== e.strokeWidth ||
                      t.fontSize !== e.fontSize ||
                      t.fontFamily !== e.fontFamily ||
                      t.fontWeight !== e.fontWeight ||
                      t.fontStyle !== e.fontStyle ||
                      t.deltaY !== e.deltaY
                    );
                  },
                  _hasStyleChangedForSvg: function (t, e) {
                    return (
                      this._hasStyleChanged(t, e) ||
                      t.overline !== e.overline ||
                      t.underline !== e.underline ||
                      t.linethrough !== e.linethrough
                    );
                  },
                  _getLineLeftOffset: function (t) {
                    var e = this.getLineWidth(t);
                    return "center" === this.textAlign
                      ? (this.width - e) / 2
                      : "right" === this.textAlign
                      ? this.width - e
                      : "justify-center" === this.textAlign && this.isEndOfWrapping(t)
                      ? (this.width - e) / 2
                      : "justify-right" === this.textAlign && this.isEndOfWrapping(t)
                      ? this.width - e
                      : 0;
                  },
                  _clearCache: function () {
                    (this.__lineWidths = []), (this.__lineHeights = []), (this.__charBounds = []);
                  },
                  _shouldClearDimensionCache: function () {
                    var t = this._forceClearCache;
                    return (
                      t || (t = this.hasStateChanged("_dimensionAffectingProps")),
                      t && ((this.dirty = !0), (this._forceClearCache = !1)),
                      t
                    );
                  },
                  getLineWidth: function (t) {
                    if (this.__lineWidths[t]) return this.__lineWidths[t];
                    var e,
                      i,
                      n = this._textLines[t];
                    return (
                      "" === n ? (e = 0) : ((i = this.measureLine(t)), (e = i.width)),
                      (this.__lineWidths[t] = e),
                      e
                    );
                  },
                  _getWidthOfCharSpacing: function () {
                    return 0 !== this.charSpacing ? (this.fontSize * this.charSpacing) / 1e3 : 0;
                  },
                  getValueOfPropertyAt: function (t, e, i) {
                    var n = this._getStyleDeclaration(t, e);
                    return n && "undefined" !== typeof n[i] ? n[i] : this[i];
                  },
                  _renderTextDecoration: function (t, e) {
                    if (this[e] || this.styleHas(e)) {
                      for (
                        var i,
                          n,
                          r,
                          s,
                          o,
                          a,
                          h,
                          c,
                          l,
                          u,
                          f,
                          d,
                          g,
                          p,
                          m,
                          v,
                          _ = this._getLeftOffset(),
                          y = this._getTopOffset(),
                          b = this._getWidthOfCharSpacing(),
                          x = 0,
                          C = this._textLines.length;
                        x < C;
                        x++
                      )
                        if (((i = this.getHeightOfLine(x)), this[e] || this.styleHas(e, x))) {
                          (h = this._textLines[x]),
                            (p = i / this.lineHeight),
                            (s = this._getLineLeftOffset(x)),
                            (u = 0),
                            (f = 0),
                            (c = this.getValueOfPropertyAt(x, 0, e)),
                            (v = this.getValueOfPropertyAt(x, 0, "fill")),
                            (l = y + p * (1 - this._fontSizeFraction)),
                            (n = this.getHeightOfChar(x, 0)),
                            (o = this.getValueOfPropertyAt(x, 0, "deltaY"));
                          for (var w = 0, S = h.length; w < S; w++)
                            (d = this.__charBounds[x][w]),
                              (g = this.getValueOfPropertyAt(x, w, e)),
                              (m = this.getValueOfPropertyAt(x, w, "fill")),
                              (r = this.getHeightOfChar(x, w)),
                              (a = this.getValueOfPropertyAt(x, w, "deltaY")),
                              (g !== c || m !== v || r !== n || a !== o) && f > 0
                                ? ((t.fillStyle = v),
                                  c &&
                                    v &&
                                    t.fillRect(
                                      _ + s + u,
                                      l + this.offsets[e] * n + o,
                                      f,
                                      this.fontSize / 15
                                    ),
                                  (u = d.left),
                                  (f = d.width),
                                  (c = g),
                                  (v = m),
                                  (n = r),
                                  (o = a))
                                : (f += d.kernedWidth);
                          (t.fillStyle = m),
                            g &&
                              m &&
                              t.fillRect(
                                _ + s + u,
                                l + this.offsets[e] * n + o,
                                f - b,
                                this.fontSize / 15
                              ),
                            (y += i);
                        } else y += i;
                      this._removeShadow(t);
                    }
                  },
                  _getFontDeclaration: function (t, i) {
                    var n = t || this,
                      r = this.fontFamily,
                      s = e.Text.genericFonts.indexOf(r.toLowerCase()) > -1,
                      o =
                        void 0 === r || r.indexOf("'") > -1 || r.indexOf('"') > -1 || s
                          ? n.fontFamily
                          : '"' + n.fontFamily + '"';
                    return [
                      e.isLikelyNode ? n.fontWeight : n.fontStyle,
                      e.isLikelyNode ? n.fontStyle : n.fontWeight,
                      i ? this.CACHE_FONT_SIZE + "px" : n.fontSize + "px",
                      o,
                    ].join(" ");
                  },
                  render: function (t) {
                    this.visible &&
                      ((this.canvas &&
                        this.canvas.skipOffscreen &&
                        !this.group &&
                        !this.isOnScreen()) ||
                        (this._shouldClearDimensionCache() && this.initDimensions(),
                        this.callSuper("render", t)));
                  },
                  _splitTextIntoLines: function (t) {
                    for (
                      var i = t.split(this._reNewline),
                        n = new Array(i.length),
                        r = ["\n"],
                        s = [],
                        o = 0;
                      o < i.length;
                      o++
                    )
                      (n[o] = e.util.string.graphemeSplit(i[o])), (s = s.concat(n[o], r));
                    return (
                      s.pop(), { _unwrappedLines: n, lines: i, graphemeText: s, graphemeLines: n }
                    );
                  },
                  toObject: function (t) {
                    var e = [
                        "text",
                        "fontSize",
                        "fontWeight",
                        "fontFamily",
                        "fontStyle",
                        "lineHeight",
                        "underline",
                        "overline",
                        "linethrough",
                        "textAlign",
                        "textBackgroundColor",
                        "charSpacing",
                      ].concat(t),
                      n = this.callSuper("toObject", e);
                    return (n.styles = i(this.styles, !0)), n;
                  },
                  set: function (t, e) {
                    this.callSuper("set", t, e);
                    var i = !1;
                    if ("object" === typeof t)
                      for (var n in t) i = i || -1 !== this._dimensionAffectingProps.indexOf(n);
                    else i = -1 !== this._dimensionAffectingProps.indexOf(t);
                    return i && (this.initDimensions(), this.setCoords()), this;
                  },
                  complexity: function () {
                    return 1;
                  },
                })),
                (e.Text.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat(
                  "x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(
                    " "
                  )
                )),
                (e.Text.DEFAULT_SVG_FONT_SIZE = 16),
                (e.Text.fromElement = function (t, n, r) {
                  if (!t) return n(null);
                  var s = e.parseAttributes(t, e.Text.ATTRIBUTE_NAMES),
                    o = s.textAnchor || "left";
                  if (
                    ((r = e.util.object.extend(r ? i(r) : {}, s)),
                    (r.top = r.top || 0),
                    (r.left = r.left || 0),
                    s.textDecoration)
                  ) {
                    var a = s.textDecoration;
                    -1 !== a.indexOf("underline") && (r.underline = !0),
                      -1 !== a.indexOf("overline") && (r.overline = !0),
                      -1 !== a.indexOf("line-through") && (r.linethrough = !0),
                      delete r.textDecoration;
                  }
                  "dx" in s && (r.left += s.dx),
                    "dy" in s && (r.top += s.dy),
                    "fontSize" in r || (r.fontSize = e.Text.DEFAULT_SVG_FONT_SIZE);
                  var h = "";
                  "textContent" in t
                    ? (h = t.textContent)
                    : "firstChild" in t &&
                      null !== t.firstChild &&
                      "data" in t.firstChild &&
                      null !== t.firstChild.data &&
                      (h = t.firstChild.data),
                    (h = h.replace(/^\s+|\s+$|\n+/g, "").replace(/\s+/g, " "));
                  var c = r.strokeWidth;
                  r.strokeWidth = 0;
                  var l = new e.Text(h, r),
                    u = l.getScaledHeight() / l.height,
                    f = (l.height + l.strokeWidth) * l.lineHeight - l.height,
                    d = f * u,
                    g = l.getScaledHeight() + d,
                    p = 0;
                  "center" === o && (p = l.getScaledWidth() / 2),
                    "right" === o && (p = l.getScaledWidth()),
                    l.set({
                      left: l.left - p,
                      top: l.top - (g - l.fontSize * (0.07 + l._fontSizeFraction)) / l.lineHeight,
                      strokeWidth: "undefined" !== typeof c ? c : 1,
                    }),
                    n(l);
                }),
                (e.Text.fromObject = function (t, i) {
                  return e.Object._fromObject("Text", t, i, "text");
                }),
                (e.Text.genericFonts = ["sans-serif", "serif", "cursive", "fantasy", "monospace"]),
                e.util.createAccessors && e.util.createAccessors(e.Text));
          })(e),
          (function () {
            n.util.object.extend(n.Text.prototype, {
              isEmptyStyles: function (t) {
                if (!this.styles) return !0;
                if ("undefined" !== typeof t && !this.styles[t]) return !0;
                var e = "undefined" === typeof t ? this.styles : { line: this.styles[t] };
                for (var i in e) for (var n in e[i]) for (var r in e[i][n]) return !1;
                return !0;
              },
              styleHas: function (t, e) {
                if (!this.styles || !t || "" === t) return !1;
                if ("undefined" !== typeof e && !this.styles[e]) return !1;
                var i = "undefined" === typeof e ? this.styles : { line: this.styles[e] };
                for (var n in i)
                  for (var r in i[n]) if ("undefined" !== typeof i[n][r][t]) return !0;
                return !1;
              },
              cleanStyle: function (t) {
                if (!this.styles || !t || "" === t) return !1;
                var e,
                  i,
                  n = this.styles,
                  r = 0,
                  s = !0,
                  o = 0;
                for (var a in n) {
                  for (var h in ((e = 0), n[a])) {
                    var c = n[a][h],
                      l = c.hasOwnProperty(t);
                    r++,
                      l
                        ? (i ? c[t] !== i && (s = !1) : (i = c[t]), c[t] === this[t] && delete c[t])
                        : (s = !1),
                      0 !== Object.keys(c).length ? e++ : delete n[a][h];
                  }
                  0 === e && delete n[a];
                }
                for (var u = 0; u < this._textLines.length; u++) o += this._textLines[u].length;
                s && r === o && ((this[t] = i), this.removeStyle(t));
              },
              removeStyle: function (t) {
                if (this.styles && t && "" !== t) {
                  var e,
                    i,
                    n,
                    r = this.styles;
                  for (i in r) {
                    for (n in ((e = r[i]), e))
                      delete e[n][t], 0 === Object.keys(e[n]).length && delete e[n];
                    0 === Object.keys(e).length && delete r[i];
                  }
                }
              },
              _extendStyles: function (t, e) {
                var i = this.get2DCursorLocation(t);
                this._getLineStyle(i.lineIndex) || this._setLineStyle(i.lineIndex, {}),
                  this._getStyleDeclaration(i.lineIndex, i.charIndex) ||
                    this._setStyleDeclaration(i.lineIndex, i.charIndex, {}),
                  n.util.object.extend(this._getStyleDeclaration(i.lineIndex, i.charIndex), e);
              },
              get2DCursorLocation: function (t, e) {
                "undefined" === typeof t && (t = this.selectionStart);
                for (
                  var i = e ? this._unwrappedTextLines : this._textLines, n = i.length, r = 0;
                  r < n;
                  r++
                ) {
                  if (t <= i[r].length) return { lineIndex: r, charIndex: t };
                  t -= i[r].length + 1;
                }
                return { lineIndex: r - 1, charIndex: i[r - 1].length < t ? i[r - 1].length : t };
              },
              getSelectionStyles: function (t, e, i) {
                "undefined" === typeof t && (t = this.selectionStart || 0),
                  "undefined" === typeof e && (e = this.selectionEnd || t);
                for (var n = [], r = t; r < e; r++) n.push(this.getStyleAtPosition(r, i));
                return n;
              },
              getStyleAtPosition: function (t, e) {
                var i = this.get2DCursorLocation(t),
                  n = e
                    ? this.getCompleteStyleDeclaration(i.lineIndex, i.charIndex)
                    : this._getStyleDeclaration(i.lineIndex, i.charIndex);
                return n || {};
              },
              setSelectionStyles: function (t, e, i) {
                "undefined" === typeof e && (e = this.selectionStart || 0),
                  "undefined" === typeof i && (i = this.selectionEnd || e);
                for (var n = e; n < i; n++) this._extendStyles(n, t);
                return (this._forceClearCache = !0), this;
              },
              _getStyleDeclaration: function (t, e) {
                var i = this.styles && this.styles[t];
                return i ? i[e] : null;
              },
              getCompleteStyleDeclaration: function (t, e) {
                for (
                  var i, n = this._getStyleDeclaration(t, e) || {}, r = {}, s = 0;
                  s < this._styleProperties.length;
                  s++
                )
                  (i = this._styleProperties[s]),
                    (r[i] = "undefined" === typeof n[i] ? this[i] : n[i]);
                return r;
              },
              _setStyleDeclaration: function (t, e, i) {
                this.styles[t][e] = i;
              },
              _deleteStyleDeclaration: function (t, e) {
                delete this.styles[t][e];
              },
              _getLineStyle: function (t) {
                return this.styles[t];
              },
              _setLineStyle: function (t, e) {
                this.styles[t] = e;
              },
              _deleteLineStyle: function (t) {
                delete this.styles[t];
              },
            });
          })(),
          (function () {
            function t(t) {
              t.textDecoration &&
                (t.textDecoration.indexOf("underline") > -1 && (t.underline = !0),
                t.textDecoration.indexOf("line-through") > -1 && (t.linethrough = !0),
                t.textDecoration.indexOf("overline") > -1 && (t.overline = !0),
                delete t.textDecoration);
            }
            (n.IText = n.util.createClass(n.Text, n.Observable, {
              type: "i-text",
              selectionStart: 0,
              selectionEnd: 0,
              selectionColor: "rgba(17,119,255,0.3)",
              isEditing: !1,
              editable: !0,
              editingBorderColor: "rgba(102,153,255,0.25)",
              cursorWidth: 2,
              cursorColor: "#333",
              cursorDelay: 1e3,
              cursorDuration: 600,
              caching: !0,
              _reSpace: /\s|\n/,
              _currentCursorOpacity: 0,
              _selectionDirection: null,
              _abortCursorAnimation: !1,
              __widthOfSpace: [],
              inCompositionMode: !1,
              initialize: function (t, e) {
                this.callSuper("initialize", t, e), this.initBehavior();
              },
              setSelectionStart: function (t) {
                (t = Math.max(t, 0)), this._updateAndFire("selectionStart", t);
              },
              setSelectionEnd: function (t) {
                (t = Math.min(t, this.text.length)), this._updateAndFire("selectionEnd", t);
              },
              _updateAndFire: function (t, e) {
                this[t] !== e && (this._fireSelectionChanged(), (this[t] = e)),
                  this._updateTextarea();
              },
              _fireSelectionChanged: function () {
                this.fire("selection:changed"),
                  this.canvas && this.canvas.fire("text:selection:changed", { target: this });
              },
              initDimensions: function () {
                this.isEditing && this.initDelayedCursor(),
                  this.clearContextTop(),
                  this.callSuper("initDimensions");
              },
              render: function (t) {
                this.clearContextTop(),
                  this.callSuper("render", t),
                  (this.cursorOffsetCache = {}),
                  this.renderCursorOrSelection();
              },
              _render: function (t) {
                this.callSuper("_render", t);
              },
              clearContextTop: function (t) {
                if (this.isEditing && this.canvas && this.canvas.contextTop) {
                  var e = this.canvas.contextTop,
                    i = this.canvas.viewportTransform;
                  e.save(),
                    e.transform(i[0], i[1], i[2], i[3], i[4], i[5]),
                    this.transform(e),
                    this.transformMatrix && e.transform.apply(e, this.transformMatrix),
                    this._clearTextArea(e),
                    t || e.restore();
                }
              },
              renderCursorOrSelection: function () {
                if (this.isEditing && this.canvas) {
                  var t,
                    e = this._getCursorBoundaries();
                  this.canvas && this.canvas.contextTop
                    ? ((t = this.canvas.contextTop), this.clearContextTop(!0))
                    : ((t = this.canvas.contextContainer), t.save()),
                    this.selectionStart === this.selectionEnd
                      ? this.renderCursor(e, t)
                      : this.renderSelection(e, t),
                    t.restore();
                }
              },
              _clearTextArea: function (t) {
                var e = this.width + 4,
                  i = this.height + 4;
                t.clearRect(-e / 2, -i / 2, e, i);
              },
              _getCursorBoundaries: function (t) {
                "undefined" === typeof t && (t = this.selectionStart);
                var e = this._getLeftOffset(),
                  i = this._getTopOffset(),
                  n = this._getCursorBoundariesOffsets(t);
                return { left: e, top: i, leftOffset: n.left, topOffset: n.top };
              },
              _getCursorBoundariesOffsets: function (t) {
                if (this.cursorOffsetCache && "top" in this.cursorOffsetCache)
                  return this.cursorOffsetCache;
                var e,
                  i,
                  n,
                  r,
                  s = 0,
                  o = 0,
                  a = this.get2DCursorLocation(t);
                (n = a.charIndex), (i = a.lineIndex);
                for (var h = 0; h < i; h++) s += this.getHeightOfLine(h);
                e = this._getLineLeftOffset(i);
                var c = this.__charBounds[i][n];
                return (
                  c && (o = c.left),
                  0 !== this.charSpacing &&
                    n === this._textLines[i].length &&
                    (o -= this._getWidthOfCharSpacing()),
                  (r = { top: s, left: e + (o > 0 ? o : 0) }),
                  (this.cursorOffsetCache = r),
                  this.cursorOffsetCache
                );
              },
              renderCursor: function (t, e) {
                var i = this.get2DCursorLocation(),
                  n = i.lineIndex,
                  r = i.charIndex > 0 ? i.charIndex - 1 : 0,
                  s = this.getValueOfPropertyAt(n, r, "fontSize"),
                  o = this.scaleX * this.canvas.getZoom(),
                  a = this.cursorWidth / o,
                  h = t.topOffset,
                  c = this.getValueOfPropertyAt(n, r, "deltaY");
                (h +=
                  ((1 - this._fontSizeFraction) * this.getHeightOfLine(n)) / this.lineHeight -
                  s * (1 - this._fontSizeFraction)),
                  this.inCompositionMode && this.renderSelection(t, e),
                  (e.fillStyle = this.getValueOfPropertyAt(n, r, "fill")),
                  (e.globalAlpha = this.__isMousedown ? 1 : this._currentCursorOpacity),
                  e.fillRect(t.left + t.leftOffset - a / 2, h + t.top + c, a, s);
              },
              renderSelection: function (t, e) {
                for (
                  var i = this.inCompositionMode
                      ? this.hiddenTextarea.selectionStart
                      : this.selectionStart,
                    n = this.inCompositionMode
                      ? this.hiddenTextarea.selectionEnd
                      : this.selectionEnd,
                    r = -1 !== this.textAlign.indexOf("justify"),
                    s = this.get2DCursorLocation(i),
                    o = this.get2DCursorLocation(n),
                    a = s.lineIndex,
                    h = o.lineIndex,
                    c = s.charIndex < 0 ? 0 : s.charIndex,
                    l = o.charIndex < 0 ? 0 : o.charIndex,
                    u = a;
                  u <= h;
                  u++
                ) {
                  var f = this._getLineLeftOffset(u) || 0,
                    d = this.getHeightOfLine(u),
                    g = 0,
                    p = 0,
                    m = 0;
                  if ((u === a && (p = this.__charBounds[a][c].left), u >= a && u < h))
                    m = r && !this.isEndOfWrapping(u) ? this.width : this.getLineWidth(u) || 5;
                  else if (u === h)
                    if (0 === l) m = this.__charBounds[h][l].left;
                    else {
                      var v = this._getWidthOfCharSpacing();
                      m = this.__charBounds[h][l - 1].left + this.__charBounds[h][l - 1].width - v;
                    }
                  (g = d),
                    (this.lineHeight < 1 || (u === h && this.lineHeight > 1)) &&
                      (d /= this.lineHeight),
                    this.inCompositionMode
                      ? ((e.fillStyle = this.compositionColor || "black"),
                        e.fillRect(t.left + f + p, t.top + t.topOffset + d, m - p, 1))
                      : ((e.fillStyle = this.selectionColor),
                        e.fillRect(t.left + f + p, t.top + t.topOffset, m - p, d)),
                    (t.topOffset += g);
                }
              },
              getCurrentCharFontSize: function () {
                var t = this._getCurrentCharIndex();
                return this.getValueOfPropertyAt(t.l, t.c, "fontSize");
              },
              getCurrentCharColor: function () {
                var t = this._getCurrentCharIndex();
                return this.getValueOfPropertyAt(t.l, t.c, "fill");
              },
              _getCurrentCharIndex: function () {
                var t = this.get2DCursorLocation(this.selectionStart, !0),
                  e = t.charIndex > 0 ? t.charIndex - 1 : 0;
                return { l: t.lineIndex, c: e };
              },
            })),
              (n.IText.fromObject = function (e, i) {
                if ((t(e), e.styles))
                  for (var r in e.styles) for (var s in e.styles[r]) t(e.styles[r][s]);
                n.Object._fromObject("IText", e, i, "text");
              });
          })(),
          (function () {
            var t = n.util.object.clone;
            n.util.object.extend(n.IText.prototype, {
              initBehavior: function () {
                this.initAddedHandler(),
                  this.initRemovedHandler(),
                  this.initCursorSelectionHandlers(),
                  this.initDoubleClickSimulation(),
                  (this.mouseMoveHandler = this.mouseMoveHandler.bind(this));
              },
              onDeselect: function () {
                this.isEditing && this.exitEditing(), (this.selected = !1);
              },
              initAddedHandler: function () {
                var t = this;
                this.on("added", function () {
                  var e = t.canvas;
                  e &&
                    (e._hasITextHandlers || ((e._hasITextHandlers = !0), t._initCanvasHandlers(e)),
                    (e._iTextInstances = e._iTextInstances || []),
                    e._iTextInstances.push(t));
                });
              },
              initRemovedHandler: function () {
                var t = this;
                this.on("removed", function () {
                  var e = t.canvas;
                  e &&
                    ((e._iTextInstances = e._iTextInstances || []),
                    n.util.removeFromArray(e._iTextInstances, t),
                    0 === e._iTextInstances.length &&
                      ((e._hasITextHandlers = !1), t._removeCanvasHandlers(e)));
                });
              },
              _initCanvasHandlers: function (t) {
                (t._mouseUpITextHandler = function () {
                  t._iTextInstances &&
                    t._iTextInstances.forEach(function (t) {
                      t.__isMousedown = !1;
                    });
                }),
                  t.on("mouse:up", t._mouseUpITextHandler);
              },
              _removeCanvasHandlers: function (t) {
                t.off("mouse:up", t._mouseUpITextHandler);
              },
              _tick: function () {
                this._currentTickState = this._animateCursor(
                  this,
                  1,
                  this.cursorDuration,
                  "_onTickComplete"
                );
              },
              _animateCursor: function (t, e, i, n) {
                var r;
                return (
                  (r = {
                    isAborted: !1,
                    abort: function () {
                      this.isAborted = !0;
                    },
                  }),
                  t.animate("_currentCursorOpacity", e, {
                    duration: i,
                    onComplete: function () {
                      r.isAborted || t[n]();
                    },
                    onChange: function () {
                      t.canvas &&
                        t.selectionStart === t.selectionEnd &&
                        t.renderCursorOrSelection();
                    },
                    abort: function () {
                      return r.isAborted;
                    },
                  }),
                  r
                );
              },
              _onTickComplete: function () {
                var t = this;
                this._cursorTimeout1 && clearTimeout(this._cursorTimeout1),
                  (this._cursorTimeout1 = setTimeout(function () {
                    t._currentTickCompleteState = t._animateCursor(
                      t,
                      0,
                      this.cursorDuration / 2,
                      "_tick"
                    );
                  }, 100));
              },
              initDelayedCursor: function (t) {
                var e = this,
                  i = t ? 0 : this.cursorDelay;
                this.abortCursorAnimation(),
                  (this._currentCursorOpacity = 1),
                  (this._cursorTimeout2 = setTimeout(function () {
                    e._tick();
                  }, i));
              },
              abortCursorAnimation: function () {
                var t = this._currentTickState || this._currentTickCompleteState,
                  e = this.canvas;
                this._currentTickState && this._currentTickState.abort(),
                  this._currentTickCompleteState && this._currentTickCompleteState.abort(),
                  clearTimeout(this._cursorTimeout1),
                  clearTimeout(this._cursorTimeout2),
                  (this._currentCursorOpacity = 0),
                  t && e && e.clearContext(e.contextTop || e.contextContainer);
              },
              selectAll: function () {
                return (
                  (this.selectionStart = 0),
                  (this.selectionEnd = this._text.length),
                  this._fireSelectionChanged(),
                  this._updateTextarea(),
                  this
                );
              },
              getSelectedText: function () {
                return this._text.slice(this.selectionStart, this.selectionEnd).join("");
              },
              findWordBoundaryLeft: function (t) {
                var e = 0,
                  i = t - 1;
                if (this._reSpace.test(this._text[i]))
                  while (this._reSpace.test(this._text[i])) e++, i--;
                while (/\S/.test(this._text[i]) && i > -1) e++, i--;
                return t - e;
              },
              findWordBoundaryRight: function (t) {
                var e = 0,
                  i = t;
                if (this._reSpace.test(this._text[i]))
                  while (this._reSpace.test(this._text[i])) e++, i++;
                while (/\S/.test(this._text[i]) && i < this.text.length) e++, i++;
                return t + e;
              },
              findLineBoundaryLeft: function (t) {
                var e = 0,
                  i = t - 1;
                while (!/\n/.test(this._text[i]) && i > -1) e++, i--;
                return t - e;
              },
              findLineBoundaryRight: function (t) {
                var e = 0,
                  i = t;
                while (!/\n/.test(this._text[i]) && i < this.text.length) e++, i++;
                return t + e;
              },
              searchWordBoundary: function (t, e) {
                var i = this._reSpace.test(this.text.charAt(t)) ? t - 1 : t,
                  n = this.text.charAt(i),
                  r = /[ \n\.,;!\?\-]/;
                while (!r.test(n) && i > 0 && i < this.text.length)
                  (i += e), (n = this.text.charAt(i));
                return r.test(n) && "\n" !== n && (i += 1 === e ? 0 : 1), i;
              },
              selectWord: function (t) {
                t = t || this.selectionStart;
                var e = this.searchWordBoundary(t, -1),
                  i = this.searchWordBoundary(t, 1);
                (this.selectionStart = e),
                  (this.selectionEnd = i),
                  this._fireSelectionChanged(),
                  this._updateTextarea(),
                  this.renderCursorOrSelection();
              },
              selectLine: function (t) {
                t = t || this.selectionStart;
                var e = this.findLineBoundaryLeft(t),
                  i = this.findLineBoundaryRight(t);
                return (
                  (this.selectionStart = e),
                  (this.selectionEnd = i),
                  this._fireSelectionChanged(),
                  this._updateTextarea(),
                  this
                );
              },
              enterEditing: function (t) {
                if (!this.isEditing && this.editable)
                  return (
                    this.canvas &&
                      (this.canvas.calcOffset(), this.exitEditingOnOthers(this.canvas)),
                    (this.isEditing = !0),
                    this.initHiddenTextarea(t),
                    this.hiddenTextarea.focus(),
                    (this.hiddenTextarea.value = this.text),
                    this._updateTextarea(),
                    this._saveEditingProps(),
                    this._setEditingProps(),
                    (this._textBeforeEdit = this.text),
                    this._tick(),
                    this.fire("editing:entered"),
                    this._fireSelectionChanged(),
                    this.canvas
                      ? (this.canvas.fire("text:editing:entered", { target: this }),
                        this.initMouseMoveHandler(),
                        this.canvas.requestRenderAll(),
                        this)
                      : this
                  );
              },
              exitEditingOnOthers: function (t) {
                t._iTextInstances &&
                  t._iTextInstances.forEach(function (t) {
                    (t.selected = !1), t.isEditing && t.exitEditing();
                  });
              },
              initMouseMoveHandler: function () {
                this.canvas.on("mouse:move", this.mouseMoveHandler);
              },
              mouseMoveHandler: function (t) {
                if (this.__isMousedown && this.isEditing) {
                  var e = this.getSelectionStartFromPointer(t.e),
                    i = this.selectionStart,
                    n = this.selectionEnd;
                  ((e === this.__selectionStartOnMouseDown && i !== n) || (i !== e && n !== e)) &&
                    (e > this.__selectionStartOnMouseDown
                      ? ((this.selectionStart = this.__selectionStartOnMouseDown),
                        (this.selectionEnd = e))
                      : ((this.selectionStart = e),
                        (this.selectionEnd = this.__selectionStartOnMouseDown)),
                    (this.selectionStart === i && this.selectionEnd === n) ||
                      (this.restartCursorIfNeeded(),
                      this._fireSelectionChanged(),
                      this._updateTextarea(),
                      this.renderCursorOrSelection()));
                }
              },
              _setEditingProps: function () {
                (this.hoverCursor = "text"),
                  this.canvas && (this.canvas.defaultCursor = this.canvas.moveCursor = "text"),
                  (this.borderColor = this.editingBorderColor),
                  (this.hasControls = this.selectable = !1),
                  (this.lockMovementX = this.lockMovementY = !0);
              },
              fromStringToGraphemeSelection: function (t, e, i) {
                var r = i.slice(0, t),
                  s = n.util.string.graphemeSplit(r).length;
                if (t === e) return { selectionStart: s, selectionEnd: s };
                var o = i.slice(t, e),
                  a = n.util.string.graphemeSplit(o).length;
                return { selectionStart: s, selectionEnd: s + a };
              },
              fromGraphemeToStringSelection: function (t, e, i) {
                var n = i.slice(0, t),
                  r = n.join("").length;
                if (t === e) return { selectionStart: r, selectionEnd: r };
                var s = i.slice(t, e),
                  o = s.join("").length;
                return { selectionStart: r, selectionEnd: r + o };
              },
              _updateTextarea: function () {
                if (((this.cursorOffsetCache = {}), this.hiddenTextarea)) {
                  if (!this.inCompositionMode) {
                    var t = this.fromGraphemeToStringSelection(
                      this.selectionStart,
                      this.selectionEnd,
                      this._text
                    );
                    (this.hiddenTextarea.selectionStart = t.selectionStart),
                      (this.hiddenTextarea.selectionEnd = t.selectionEnd);
                  }
                  this.updateTextareaPosition();
                }
              },
              updateFromTextArea: function () {
                if (this.hiddenTextarea) {
                  (this.cursorOffsetCache = {}),
                    (this.text = this.hiddenTextarea.value),
                    this._shouldClearDimensionCache() && (this.initDimensions(), this.setCoords());
                  var t = this.fromStringToGraphemeSelection(
                    this.hiddenTextarea.selectionStart,
                    this.hiddenTextarea.selectionEnd,
                    this.hiddenTextarea.value
                  );
                  (this.selectionEnd = this.selectionStart = t.selectionEnd),
                    this.inCompositionMode || (this.selectionStart = t.selectionStart),
                    this.updateTextareaPosition();
                }
              },
              updateTextareaPosition: function () {
                if (this.selectionStart === this.selectionEnd) {
                  var t = this._calcTextareaPosition();
                  (this.hiddenTextarea.style.left = t.left),
                    (this.hiddenTextarea.style.top = t.top);
                }
              },
              _calcTextareaPosition: function () {
                if (!this.canvas) return { x: 1, y: 1 };
                var t = this.inCompositionMode ? this.compositionStart : this.selectionStart,
                  e = this._getCursorBoundaries(t),
                  i = this.get2DCursorLocation(t),
                  r = i.lineIndex,
                  s = i.charIndex,
                  o = this.getValueOfPropertyAt(r, s, "fontSize") * this.lineHeight,
                  a = e.leftOffset,
                  h = this.calcTransformMatrix(),
                  c = { x: e.left + a, y: e.top + e.topOffset + o },
                  l = this.canvas.upperCanvasEl,
                  u = l.width,
                  f = l.height,
                  d = u - o,
                  g = f - o,
                  p = l.clientWidth / u,
                  m = l.clientHeight / f;
                return (
                  (c = n.util.transformPoint(c, h)),
                  (c = n.util.transformPoint(c, this.canvas.viewportTransform)),
                  (c.x *= p),
                  (c.y *= m),
                  c.x < 0 && (c.x = 0),
                  c.x > d && (c.x = d),
                  c.y < 0 && (c.y = 0),
                  c.y > g && (c.y = g),
                  (c.x += this.canvas._offset.left),
                  (c.y += this.canvas._offset.top),
                  { left: c.x + "px", top: c.y + "px", fontSize: o + "px", charHeight: o }
                );
              },
              _saveEditingProps: function () {
                this._savedProps = {
                  hasControls: this.hasControls,
                  borderColor: this.borderColor,
                  lockMovementX: this.lockMovementX,
                  lockMovementY: this.lockMovementY,
                  hoverCursor: this.hoverCursor,
                  defaultCursor: this.canvas && this.canvas.defaultCursor,
                  moveCursor: this.canvas && this.canvas.moveCursor,
                };
              },
              _restoreEditingProps: function () {
                this._savedProps &&
                  ((this.hoverCursor = this._savedProps.hoverCursor),
                  (this.hasControls = this._savedProps.hasControls),
                  (this.borderColor = this._savedProps.borderColor),
                  (this.lockMovementX = this._savedProps.lockMovementX),
                  (this.lockMovementY = this._savedProps.lockMovementY),
                  this.canvas &&
                    ((this.canvas.defaultCursor = this._savedProps.defaultCursor),
                    (this.canvas.moveCursor = this._savedProps.moveCursor)));
              },
              exitEditing: function () {
                var t = this._textBeforeEdit !== this.text;
                return (
                  (this.selected = !1),
                  (this.isEditing = !1),
                  (this.selectable = !0),
                  (this.selectionEnd = this.selectionStart),
                  this.hiddenTextarea &&
                    (this.hiddenTextarea.blur && this.hiddenTextarea.blur(),
                    this.canvas && this.hiddenTextarea.parentNode.removeChild(this.hiddenTextarea),
                    (this.hiddenTextarea = null)),
                  this.abortCursorAnimation(),
                  this._restoreEditingProps(),
                  (this._currentCursorOpacity = 0),
                  this._shouldClearDimensionCache() && (this.initDimensions(), this.setCoords()),
                  this.fire("editing:exited"),
                  t && this.fire("modified"),
                  this.canvas &&
                    (this.canvas.off("mouse:move", this.mouseMoveHandler),
                    this.canvas.fire("text:editing:exited", { target: this }),
                    t && this.canvas.fire("object:modified", { target: this })),
                  this
                );
              },
              _removeExtraneousStyles: function () {
                for (var t in this.styles) this._textLines[t] || delete this.styles[t];
              },
              removeStyleFromTo: function (t, e) {
                var i,
                  n,
                  r = this.get2DCursorLocation(t, !0),
                  s = this.get2DCursorLocation(e, !0),
                  o = r.lineIndex,
                  a = r.charIndex,
                  h = s.lineIndex,
                  c = s.charIndex;
                if (o !== h) {
                  if (this.styles[o])
                    for (i = a; i < this._unwrappedTextLines[o].length; i++)
                      delete this.styles[o][i];
                  if (this.styles[h])
                    for (i = c; i < this._unwrappedTextLines[h].length; i++)
                      (n = this.styles[h][i]),
                        n &&
                          (this.styles[o] || (this.styles[o] = {}),
                          (this.styles[o][a + i - c] = n));
                  for (i = o + 1; i <= h; i++) delete this.styles[i];
                  this.shiftLineStyles(h, o - h);
                } else if (this.styles[o]) {
                  n = this.styles[o];
                  var l,
                    u,
                    f = c - a;
                  for (i = a; i < c; i++) delete n[i];
                  for (u in this.styles[o])
                    (l = parseInt(u, 10)), l >= c && ((n[l - f] = n[u]), delete n[u]);
                }
              },
              shiftLineStyles: function (e, i) {
                var n = t(this.styles);
                for (var r in this.styles) {
                  var s = parseInt(r, 10);
                  s > e && ((this.styles[s + i] = n[s]), n[s - i] || delete this.styles[s]);
                }
              },
              restartCursorIfNeeded: function () {
                (this._currentTickState &&
                  !this._currentTickState.isAborted &&
                  this._currentTickCompleteState &&
                  !this._currentTickCompleteState.isAborted) ||
                  this.initDelayedCursor();
              },
              insertNewlineStyleObject: function (e, i, n, r) {
                var s,
                  o = {},
                  a = !1;
                for (var h in (n || (n = 1),
                this.shiftLineStyles(e, n),
                this.styles[e] && (s = this.styles[e][0 === i ? i : i - 1]),
                this.styles[e])) {
                  var c = parseInt(h, 10);
                  c >= i && ((a = !0), (o[c - i] = this.styles[e][h]), delete this.styles[e][h]);
                }
                a ? (this.styles[e + n] = o) : delete this.styles[e + n];
                while (n > 1)
                  n--,
                    r && r[n]
                      ? (this.styles[e + n] = { 0: t(r[n]) })
                      : s
                      ? (this.styles[e + n] = { 0: t(s) })
                      : delete this.styles[e + n];
                this._forceClearCache = !0;
              },
              insertCharStyleObject: function (e, i, n, r) {
                this.styles || (this.styles = {});
                var s = this.styles[e],
                  o = s ? t(s) : {};
                for (var a in (n || (n = 1), o)) {
                  var h = parseInt(a, 10);
                  h >= i && ((s[h + n] = o[h]), o[h - n] || delete s[h]);
                }
                if (((this._forceClearCache = !0), r))
                  while (n--)
                    Object.keys(r[n]).length &&
                      (this.styles[e] || (this.styles[e] = {}), (this.styles[e][i + n] = t(r[n])));
                else if (s) {
                  var c = s[i ? i - 1 : 1];
                  while (c && n--) this.styles[e][i + n] = t(c);
                }
              },
              insertNewStyleBlock: function (t, e, i) {
                for (
                  var n = this.get2DCursorLocation(e, !0), r = [0], s = 0, o = 0;
                  o < t.length;
                  o++
                )
                  "\n" === t[o] ? (s++, (r[s] = 0)) : r[s]++;
                r[0] > 0 &&
                  (this.insertCharStyleObject(n.lineIndex, n.charIndex, r[0], i),
                  (i = i && i.slice(r[0] + 1))),
                  s && this.insertNewlineStyleObject(n.lineIndex, n.charIndex + r[0], s);
                for (o = 1; o < s; o++)
                  r[o] > 0
                    ? this.insertCharStyleObject(n.lineIndex + o, 0, r[o], i)
                    : i && (this.styles[n.lineIndex + o][0] = i[0]),
                    (i = i && i.slice(r[o] + 1));
                r[o] > 0 && this.insertCharStyleObject(n.lineIndex + o, 0, r[o], i);
              },
              setSelectionStartEndWithShift: function (t, e, i) {
                i <= t
                  ? (e === t
                      ? (this._selectionDirection = "left")
                      : "right" === this._selectionDirection &&
                        ((this._selectionDirection = "left"), (this.selectionEnd = t)),
                    (this.selectionStart = i))
                  : i > t && i < e
                  ? "right" === this._selectionDirection
                    ? (this.selectionEnd = i)
                    : (this.selectionStart = i)
                  : (e === t
                      ? (this._selectionDirection = "right")
                      : "left" === this._selectionDirection &&
                        ((this._selectionDirection = "right"), (this.selectionStart = e)),
                    (this.selectionEnd = i));
              },
              setSelectionInBoundaries: function () {
                var t = this.text.length;
                this.selectionStart > t
                  ? (this.selectionStart = t)
                  : this.selectionStart < 0 && (this.selectionStart = 0),
                  this.selectionEnd > t
                    ? (this.selectionEnd = t)
                    : this.selectionEnd < 0 && (this.selectionEnd = 0);
              },
            });
          })(),
          n.util.object.extend(n.IText.prototype, {
            initDoubleClickSimulation: function () {
              (this.__lastClickTime = +new Date()),
                (this.__lastLastClickTime = +new Date()),
                (this.__lastPointer = {}),
                this.on("mousedown", this.onMouseDown);
            },
            onMouseDown: function (t) {
              if (this.canvas) {
                this.__newClickTime = +new Date();
                var e = t.pointer;
                this.isTripleClick(e) && (this.fire("tripleclick", t), this._stopEvent(t.e)),
                  (this.__lastLastClickTime = this.__lastClickTime),
                  (this.__lastClickTime = this.__newClickTime),
                  (this.__lastPointer = e),
                  (this.__lastIsEditing = this.isEditing),
                  (this.__lastSelected = this.selected);
              }
            },
            isTripleClick: function (t) {
              return (
                this.__newClickTime - this.__lastClickTime < 500 &&
                this.__lastClickTime - this.__lastLastClickTime < 500 &&
                this.__lastPointer.x === t.x &&
                this.__lastPointer.y === t.y
              );
            },
            _stopEvent: function (t) {
              t.preventDefault && t.preventDefault(), t.stopPropagation && t.stopPropagation();
            },
            initCursorSelectionHandlers: function () {
              this.initMousedownHandler(), this.initMouseupHandler(), this.initClicks();
            },
            initClicks: function () {
              this.on("mousedblclick", function (t) {
                this.selectWord(this.getSelectionStartFromPointer(t.e));
              }),
                this.on("tripleclick", function (t) {
                  this.selectLine(this.getSelectionStartFromPointer(t.e));
                });
            },
            _mouseDownHandler: function (t) {
              !this.canvas ||
                !this.editable ||
                (t.e.button && 1 !== t.e.button) ||
                ((this.__isMousedown = !0),
                this.selected && this.setCursorByClick(t.e),
                this.isEditing &&
                  ((this.__selectionStartOnMouseDown = this.selectionStart),
                  this.selectionStart === this.selectionEnd && this.abortCursorAnimation(),
                  this.renderCursorOrSelection()));
            },
            _mouseDownHandlerBefore: function (t) {
              !this.canvas ||
                !this.editable ||
                (t.e.button && 1 !== t.e.button) ||
                (this === this.canvas._activeObject && (this.selected = !0));
            },
            initMousedownHandler: function () {
              this.on("mousedown", this._mouseDownHandler),
                this.on("mousedown:before", this._mouseDownHandlerBefore);
            },
            initMouseupHandler: function () {
              this.on("mouseup", this.mouseUpHandler);
            },
            mouseUpHandler: function (t) {
              if (
                ((this.__isMousedown = !1),
                !(
                  !this.editable ||
                  this.group ||
                  (t.transform && t.transform.actionPerformed) ||
                  (t.e.button && 1 !== t.e.button)
                ))
              ) {
                if (this.canvas) {
                  var e = this.canvas._activeObject;
                  if (e && e !== this) return;
                }
                this.__lastSelected && !this.__corner
                  ? ((this.selected = !1),
                    (this.__lastSelected = !1),
                    this.enterEditing(t.e),
                    this.selectionStart === this.selectionEnd
                      ? this.initDelayedCursor(!0)
                      : this.renderCursorOrSelection())
                  : (this.selected = !0);
              }
            },
            setCursorByClick: function (t) {
              var e = this.getSelectionStartFromPointer(t),
                i = this.selectionStart,
                n = this.selectionEnd;
              t.shiftKey
                ? this.setSelectionStartEndWithShift(i, n, e)
                : ((this.selectionStart = e), (this.selectionEnd = e)),
                this.isEditing && (this._fireSelectionChanged(), this._updateTextarea());
            },
            getSelectionStartFromPointer: function (t) {
              for (
                var e,
                  i,
                  n = this.getLocalPointer(t),
                  r = 0,
                  s = 0,
                  o = 0,
                  a = 0,
                  h = 0,
                  c = 0,
                  l = this._textLines.length;
                c < l;
                c++
              ) {
                if (!(o <= n.y)) break;
                (o += this.getHeightOfLine(c) * this.scaleY),
                  (h = c),
                  c > 0 && (a += this._textLines[c - 1].length + 1);
              }
              (e = this._getLineLeftOffset(h)), (s = e * this.scaleX), (i = this._textLines[h]);
              for (var u = 0, f = i.length; u < f; u++) {
                if (
                  ((r = s), (s += this.__charBounds[h][u].kernedWidth * this.scaleX), !(s <= n.x))
                )
                  break;
                a++;
              }
              return this._getNewSelectionStartFromOffset(n, r, s, a, f);
            },
            _getNewSelectionStartFromOffset: function (t, e, i, n, r) {
              var s = t.x - e,
                o = i - t.x,
                a = o > s || o < 0 ? 0 : 1,
                h = n + a;
              return this.flipX && (h = r - h), h > this._text.length && (h = this._text.length), h;
            },
          }),
          n.util.object.extend(n.IText.prototype, {
            initHiddenTextarea: function () {
              (this.hiddenTextarea = n.document.createElement("textarea")),
                this.hiddenTextarea.setAttribute("autocapitalize", "off"),
                this.hiddenTextarea.setAttribute("autocorrect", "off"),
                this.hiddenTextarea.setAttribute("autocomplete", "off"),
                this.hiddenTextarea.setAttribute("spellcheck", "false"),
                this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea", ""),
                this.hiddenTextarea.setAttribute("wrap", "off");
              var t = this._calcTextareaPosition();
              (this.hiddenTextarea.style.cssText =
                "position: absolute; top: " +
                t.top +
                "; left: " +
                t.left +
                "; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; paddingｰtop: " +
                t.fontSize +
                ";"),
                n.document.body.appendChild(this.hiddenTextarea),
                n.util.addListener(this.hiddenTextarea, "keydown", this.onKeyDown.bind(this)),
                n.util.addListener(this.hiddenTextarea, "keyup", this.onKeyUp.bind(this)),
                n.util.addListener(this.hiddenTextarea, "input", this.onInput.bind(this)),
                n.util.addListener(this.hiddenTextarea, "copy", this.copy.bind(this)),
                n.util.addListener(this.hiddenTextarea, "cut", this.copy.bind(this)),
                n.util.addListener(this.hiddenTextarea, "paste", this.paste.bind(this)),
                n.util.addListener(
                  this.hiddenTextarea,
                  "compositionstart",
                  this.onCompositionStart.bind(this)
                ),
                n.util.addListener(
                  this.hiddenTextarea,
                  "compositionupdate",
                  this.onCompositionUpdate.bind(this)
                ),
                n.util.addListener(
                  this.hiddenTextarea,
                  "compositionend",
                  this.onCompositionEnd.bind(this)
                ),
                !this._clickHandlerInitialized &&
                  this.canvas &&
                  (n.util.addListener(this.canvas.upperCanvasEl, "click", this.onClick.bind(this)),
                  (this._clickHandlerInitialized = !0));
            },
            keysMap: {
              9: "exitEditing",
              27: "exitEditing",
              33: "moveCursorUp",
              34: "moveCursorDown",
              35: "moveCursorRight",
              36: "moveCursorLeft",
              37: "moveCursorLeft",
              38: "moveCursorUp",
              39: "moveCursorRight",
              40: "moveCursorDown",
            },
            ctrlKeysMapUp: { 67: "copy", 88: "cut" },
            ctrlKeysMapDown: { 65: "selectAll" },
            onClick: function () {
              this.hiddenTextarea && this.hiddenTextarea.focus();
            },
            onKeyDown: function (t) {
              if (this.isEditing && !this.inCompositionMode) {
                if (t.keyCode in this.keysMap) this[this.keysMap[t.keyCode]](t);
                else {
                  if (!(t.keyCode in this.ctrlKeysMapDown) || (!t.ctrlKey && !t.metaKey)) return;
                  this[this.ctrlKeysMapDown[t.keyCode]](t);
                }
                t.stopImmediatePropagation(),
                  t.preventDefault(),
                  t.keyCode >= 33 && t.keyCode <= 40
                    ? (this.clearContextTop(), this.renderCursorOrSelection())
                    : this.canvas && this.canvas.requestRenderAll();
              }
            },
            onKeyUp: function (t) {
              !this.isEditing || this._copyDone || this.inCompositionMode
                ? (this._copyDone = !1)
                : t.keyCode in this.ctrlKeysMapUp &&
                  (t.ctrlKey || t.metaKey) &&
                  (this[this.ctrlKeysMapUp[t.keyCode]](t),
                  t.stopImmediatePropagation(),
                  t.preventDefault(),
                  this.canvas && this.canvas.requestRenderAll());
            },
            onInput: function (t) {
              var e = this.fromPaste;
              if (((this.fromPaste = !1), t && t.stopPropagation(), this.isEditing)) {
                var i,
                  r,
                  s = this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,
                  o = this._text.length,
                  a = s.length,
                  h = a - o;
                if ("" === this.hiddenTextarea.value)
                  return (
                    (this.styles = {}),
                    this.updateFromTextArea(),
                    this.fire("changed"),
                    void (
                      this.canvas &&
                      (this.canvas.fire("text:changed", { target: this }),
                      this.canvas.requestRenderAll())
                    )
                  );
                var c = this.fromStringToGraphemeSelection(
                    this.hiddenTextarea.selectionStart,
                    this.hiddenTextarea.selectionEnd,
                    this.hiddenTextarea.value
                  ),
                  l = this.selectionStart > c.selectionStart;
                this.selectionStart !== this.selectionEnd
                  ? ((i = this._text.slice(this.selectionStart, this.selectionEnd)),
                    (h += this.selectionEnd - this.selectionStart))
                  : a < o &&
                    (i = l
                      ? this._text.slice(this.selectionEnd + h, this.selectionEnd)
                      : this._text.slice(this.selectionStart, this.selectionStart - h)),
                  (r = s.slice(c.selectionEnd - h, c.selectionEnd)),
                  i &&
                    i.length &&
                    (this.selectionStart !== this.selectionEnd
                      ? this.removeStyleFromTo(this.selectionStart, this.selectionEnd)
                      : l
                      ? this.removeStyleFromTo(this.selectionEnd - i.length, this.selectionEnd)
                      : this.removeStyleFromTo(this.selectionEnd, this.selectionEnd + i.length)),
                  r.length &&
                    (e && r.join("") === n.copiedText
                      ? this.insertNewStyleBlock(r, this.selectionStart, n.copiedTextStyle)
                      : this.insertNewStyleBlock(r, this.selectionStart)),
                  this.updateFromTextArea(),
                  this.fire("changed"),
                  this.canvas &&
                    (this.canvas.fire("text:changed", { target: this }),
                    this.canvas.requestRenderAll());
              }
            },
            onCompositionStart: function () {
              this.inCompositionMode = !0;
            },
            onCompositionEnd: function () {
              this.inCompositionMode = !1;
            },
            onCompositionUpdate: function (t) {
              (this.compositionStart = t.target.selectionStart),
                (this.compositionEnd = t.target.selectionEnd),
                this.updateTextareaPosition();
            },
            copy: function () {
              this.selectionStart !== this.selectionEnd &&
                ((n.copiedText = this.getSelectedText()),
                (n.copiedTextStyle = this.getSelectionStyles(
                  this.selectionStart,
                  this.selectionEnd,
                  !0
                )),
                (this._copyDone = !0));
            },
            paste: function () {
              this.fromPaste = !0;
            },
            _getClipboardData: function (t) {
              return (t && t.clipboardData) || n.window.clipboardData;
            },
            _getWidthBeforeCursor: function (t, e) {
              var i,
                n = this._getLineLeftOffset(t);
              return e > 0 && ((i = this.__charBounds[t][e - 1]), (n += i.left + i.width)), n;
            },
            getDownCursorOffset: function (t, e) {
              var i = this._getSelectionForOffset(t, e),
                n = this.get2DCursorLocation(i),
                r = n.lineIndex;
              if (r === this._textLines.length - 1 || t.metaKey || 34 === t.keyCode)
                return this._text.length - i;
              var s = n.charIndex,
                o = this._getWidthBeforeCursor(r, s),
                a = this._getIndexOnLine(r + 1, o),
                h = this._textLines[r].slice(s);
              return h.length + a + 2;
            },
            _getSelectionForOffset: function (t, e) {
              return t.shiftKey && this.selectionStart !== this.selectionEnd && e
                ? this.selectionEnd
                : this.selectionStart;
            },
            getUpCursorOffset: function (t, e) {
              var i = this._getSelectionForOffset(t, e),
                n = this.get2DCursorLocation(i),
                r = n.lineIndex;
              if (0 === r || t.metaKey || 33 === t.keyCode) return -i;
              var s = n.charIndex,
                o = this._getWidthBeforeCursor(r, s),
                a = this._getIndexOnLine(r - 1, o),
                h = this._textLines[r].slice(0, s);
              return -this._textLines[r - 1].length + a - h.length;
            },
            _getIndexOnLine: function (t, e) {
              for (
                var i,
                  n,
                  r = this._textLines[t],
                  s = this._getLineLeftOffset(t),
                  o = s,
                  a = 0,
                  h = 0,
                  c = r.length;
                h < c;
                h++
              )
                if (((i = this.__charBounds[t][h].width), (o += i), o > e)) {
                  n = !0;
                  var l = o - i,
                    u = o,
                    f = Math.abs(l - e),
                    d = Math.abs(u - e);
                  a = d < f ? h : h - 1;
                  break;
                }
              return n || (a = r.length - 1), a;
            },
            moveCursorDown: function (t) {
              (this.selectionStart >= this._text.length &&
                this.selectionEnd >= this._text.length) ||
                this._moveCursorUpOrDown("Down", t);
            },
            moveCursorUp: function (t) {
              (0 === this.selectionStart && 0 === this.selectionEnd) ||
                this._moveCursorUpOrDown("Up", t);
            },
            _moveCursorUpOrDown: function (t, e) {
              var i = "get" + t + "CursorOffset",
                n = this[i](e, "right" === this._selectionDirection);
              e.shiftKey ? this.moveCursorWithShift(n) : this.moveCursorWithoutShift(n),
                0 !== n &&
                  (this.setSelectionInBoundaries(),
                  this.abortCursorAnimation(),
                  (this._currentCursorOpacity = 1),
                  this.initDelayedCursor(),
                  this._fireSelectionChanged(),
                  this._updateTextarea());
            },
            moveCursorWithShift: function (t) {
              var e =
                "left" === this._selectionDirection
                  ? this.selectionStart + t
                  : this.selectionEnd + t;
              return (
                this.setSelectionStartEndWithShift(this.selectionStart, this.selectionEnd, e),
                0 !== t
              );
            },
            moveCursorWithoutShift: function (t) {
              return (
                t < 0
                  ? ((this.selectionStart += t), (this.selectionEnd = this.selectionStart))
                  : ((this.selectionEnd += t), (this.selectionStart = this.selectionEnd)),
                0 !== t
              );
            },
            moveCursorLeft: function (t) {
              (0 === this.selectionStart && 0 === this.selectionEnd) ||
                this._moveCursorLeftOrRight("Left", t);
            },
            _move: function (t, e, i) {
              var n;
              if (t.altKey) n = this["findWordBoundary" + i](this[e]);
              else {
                if (!t.metaKey && 35 !== t.keyCode && 36 !== t.keyCode)
                  return (this[e] += "Left" === i ? -1 : 1), !0;
                n = this["findLineBoundary" + i](this[e]);
              }
              if (void 0 !== typeof n && this[e] !== n) return (this[e] = n), !0;
            },
            _moveLeft: function (t, e) {
              return this._move(t, e, "Left");
            },
            _moveRight: function (t, e) {
              return this._move(t, e, "Right");
            },
            moveCursorLeftWithoutShift: function (t) {
              var e = !0;
              return (
                (this._selectionDirection = "left"),
                this.selectionEnd === this.selectionStart &&
                  0 !== this.selectionStart &&
                  (e = this._moveLeft(t, "selectionStart")),
                (this.selectionEnd = this.selectionStart),
                e
              );
            },
            moveCursorLeftWithShift: function (t) {
              return "right" === this._selectionDirection &&
                this.selectionStart !== this.selectionEnd
                ? this._moveLeft(t, "selectionEnd")
                : 0 !== this.selectionStart
                ? ((this._selectionDirection = "left"), this._moveLeft(t, "selectionStart"))
                : void 0;
            },
            moveCursorRight: function (t) {
              (this.selectionStart >= this._text.length &&
                this.selectionEnd >= this._text.length) ||
                this._moveCursorLeftOrRight("Right", t);
            },
            _moveCursorLeftOrRight: function (t, e) {
              var i = "moveCursor" + t + "With";
              (this._currentCursorOpacity = 1),
                e.shiftKey ? (i += "Shift") : (i += "outShift"),
                this[i](e) &&
                  (this.abortCursorAnimation(),
                  this.initDelayedCursor(),
                  this._fireSelectionChanged(),
                  this._updateTextarea());
            },
            moveCursorRightWithShift: function (t) {
              return "left" === this._selectionDirection &&
                this.selectionStart !== this.selectionEnd
                ? this._moveRight(t, "selectionStart")
                : this.selectionEnd !== this._text.length
                ? ((this._selectionDirection = "right"), this._moveRight(t, "selectionEnd"))
                : void 0;
            },
            moveCursorRightWithoutShift: function (t) {
              var e = !0;
              return (
                (this._selectionDirection = "right"),
                this.selectionStart === this.selectionEnd
                  ? ((e = this._moveRight(t, "selectionStart")),
                    (this.selectionEnd = this.selectionStart))
                  : (this.selectionStart = this.selectionEnd),
                e
              );
            },
            removeChars: function (t, e) {
              "undefined" === typeof e && (e = t + 1),
                this.removeStyleFromTo(t, e),
                this._text.splice(t, e - t),
                (this.text = this._text.join("")),
                this.set("dirty", !0),
                this._shouldClearDimensionCache() && (this.initDimensions(), this.setCoords()),
                this._removeExtraneousStyles();
            },
            insertChars: function (t, e, i, r) {
              "undefined" === typeof r && (r = i), r > i && this.removeStyleFromTo(i, r);
              var s = n.util.string.graphemeSplit(t);
              this.insertNewStyleBlock(s, i, e),
                (this._text = [].concat(this._text.slice(0, i), s, this._text.slice(r))),
                (this.text = this._text.join("")),
                this.set("dirty", !0),
                this._shouldClearDimensionCache() && (this.initDimensions(), this.setCoords()),
                this._removeExtraneousStyles();
            },
          }),
          (function () {
            var t = n.util.toFixed,
              e = /  +/g;
            n.util.object.extend(n.Text.prototype, {
              toSVG: function (t) {
                var e = this._getSVGLeftTopOffsets(),
                  i = this._getSVGTextAndBg(e.textTop, e.textLeft),
                  n = this._wrapSVGTextAndBg(i);
                return this._createBaseSVGMarkup(n, { reviver: t, noStyle: !0, withShadow: !0 });
              },
              _getSVGLeftTopOffsets: function () {
                return {
                  textLeft: -this.width / 2,
                  textTop: -this.height / 2,
                  lineTop: this.getHeightOfLine(0),
                };
              },
              _wrapSVGTextAndBg: function (t) {
                var e = !0,
                  i = this.getSvgTextDecoration(this);
                return [
                  t.textBgRects.join(""),
                  '\t\t<text xml:space="preserve" ',
                  this.fontFamily
                    ? 'font-family="' + this.fontFamily.replace(/"/g, "'") + '" '
                    : "",
                  this.fontSize ? 'font-size="' + this.fontSize + '" ' : "",
                  this.fontStyle ? 'font-style="' + this.fontStyle + '" ' : "",
                  this.fontWeight ? 'font-weight="' + this.fontWeight + '" ' : "",
                  i ? 'text-decoration="' + i + '" ' : "",
                  'style="',
                  this.getSvgStyles(e),
                  '"',
                  this.addPaintOrder(),
                  " >",
                  t.textSpans.join(""),
                  "</text>\n",
                ];
              },
              _getSVGTextAndBg: function (t, e) {
                var i,
                  n = [],
                  r = [],
                  s = t;
                this._setSVGBg(r);
                for (var o = 0, a = this._textLines.length; o < a; o++)
                  (i = this._getLineLeftOffset(o)),
                    (this.textBackgroundColor || this.styleHas("textBackgroundColor", o)) &&
                      this._setSVGTextLineBg(r, o, e + i, s),
                    this._setSVGTextLineText(n, o, e + i, s),
                    (s += this.getHeightOfLine(o));
                return { textSpans: n, textBgRects: r };
              },
              _createTextCharSpan: function (i, r, s, o) {
                var a = i !== i.trim() || i.match(e),
                  h = this.getSvgSpanStyles(r, a),
                  c = h ? 'style="' + h + '"' : "",
                  l = r.deltaY,
                  u = "",
                  f = n.Object.NUM_FRACTION_DIGITS;
                return (
                  l && (u = ' dy="' + t(l, f) + '" '),
                  [
                    '<tspan x="',
                    t(s, f),
                    '" y="',
                    t(o, f),
                    '" ',
                    u,
                    c,
                    ">",
                    n.util.string.escapeXml(i),
                    "</tspan>",
                  ].join("")
                );
              },
              _setSVGTextLineText: function (t, e, i, n) {
                var r,
                  s,
                  o,
                  a,
                  h,
                  c = this.getHeightOfLine(e),
                  l = -1 !== this.textAlign.indexOf("justify"),
                  u = "",
                  f = 0,
                  d = this._textLines[e];
                n += (c * (1 - this._fontSizeFraction)) / this.lineHeight;
                for (var g = 0, p = d.length - 1; g <= p; g++)
                  (h = g === p || this.charSpacing),
                    (u += d[g]),
                    (o = this.__charBounds[e][g]),
                    0 === f
                      ? ((i += o.kernedWidth - o.width), (f += o.width))
                      : (f += o.kernedWidth),
                    l && !h && this._reSpaceAndTab.test(d[g]) && (h = !0),
                    h ||
                      ((r = r || this.getCompleteStyleDeclaration(e, g)),
                      (s = this.getCompleteStyleDeclaration(e, g + 1)),
                      (h = this._hasStyleChangedForSvg(r, s))),
                    h &&
                      ((a = this._getStyleDeclaration(e, g) || {}),
                      t.push(this._createTextCharSpan(u, a, i, n)),
                      (u = ""),
                      (r = s),
                      (i += f),
                      (f = 0));
              },
              _pushTextBgRect: function (e, i, r, s, o, a) {
                var h = n.Object.NUM_FRACTION_DIGITS;
                e.push(
                  "\t\t<rect ",
                  this._getFillAttributes(i),
                  ' x="',
                  t(r, h),
                  '" y="',
                  t(s, h),
                  '" width="',
                  t(o, h),
                  '" height="',
                  t(a, h),
                  '"></rect>\n'
                );
              },
              _setSVGTextLineBg: function (t, e, i, n) {
                for (
                  var r,
                    s,
                    o = this._textLines[e],
                    a = this.getHeightOfLine(e) / this.lineHeight,
                    h = 0,
                    c = 0,
                    l = this.getValueOfPropertyAt(e, 0, "textBackgroundColor"),
                    u = 0,
                    f = o.length;
                  u < f;
                  u++
                )
                  (r = this.__charBounds[e][u]),
                    (s = this.getValueOfPropertyAt(e, u, "textBackgroundColor")),
                    s !== l
                      ? (l && this._pushTextBgRect(t, l, i + c, n, h, a),
                        (c = r.left),
                        (h = r.width),
                        (l = s))
                      : (h += r.kernedWidth);
                s && this._pushTextBgRect(t, s, i + c, n, h, a);
              },
              _getFillAttributes: function (t) {
                var e = t && "string" === typeof t ? new n.Color(t) : "";
                return e && e.getSource() && 1 !== e.getAlpha()
                  ? 'opacity="' + e.getAlpha() + '" fill="' + e.setAlpha(1).toRgb() + '"'
                  : 'fill="' + t + '"';
              },
              _getSVGLineTopOffset: function (t) {
                for (var e = 0, i = 0, n = 0; n < t; n++) e += this.getHeightOfLine(n);
                return (
                  (i = this.getHeightOfLine(n)),
                  {
                    lineTop: e,
                    offset:
                      ((this._fontSizeMult - this._fontSizeFraction) * i) /
                      (this.lineHeight * this._fontSizeMult),
                  }
                );
              },
              getSvgStyles: function (t) {
                var e = n.Object.prototype.getSvgStyles.call(this, t);
                return e + " white-space: pre;";
              },
            });
          })(),
          (function (t) {
            "use strict";
            var e = t.fabric || (t.fabric = {});
            (e.Textbox = e.util.createClass(e.IText, e.Observable, {
              type: "textbox",
              minWidth: 20,
              dynamicMinWidth: 2,
              __cachedLines: null,
              lockScalingFlip: !0,
              noScaleCache: !1,
              _dimensionAffectingProps: e.Text.prototype._dimensionAffectingProps.concat("width"),
              _wordJoiners: /[ \t\r]/,
              splitByGrapheme: !1,
              initDimensions: function () {
                this.__skipDimension ||
                  (this.isEditing && this.initDelayedCursor(),
                  this.clearContextTop(),
                  this._clearCache(),
                  (this.dynamicMinWidth = 0),
                  (this._styleMap = this._generateStyleMap(this._splitText())),
                  this.dynamicMinWidth > this.width && this._set("width", this.dynamicMinWidth),
                  -1 !== this.textAlign.indexOf("justify") && this.enlargeSpaces(),
                  (this.height = this.calcTextHeight()),
                  this.saveState({ propertySet: "_dimensionAffectingProps" }));
              },
              _generateStyleMap: function (t) {
                for (var e = 0, i = 0, n = 0, r = {}, s = 0; s < t.graphemeLines.length; s++)
                  "\n" === t.graphemeText[n] && s > 0
                    ? ((i = 0), n++, e++)
                    : !this.graphemeSplit &&
                      this._reSpaceAndTab.test(t.graphemeText[n]) &&
                      s > 0 &&
                      (i++, n++),
                    (r[s] = { line: e, offset: i }),
                    (n += t.graphemeLines[s].length),
                    (i += t.graphemeLines[s].length);
                return r;
              },
              styleHas: function (t, i) {
                if (this._styleMap && !this.isWrapping) {
                  var n = this._styleMap[i];
                  n && (i = n.line);
                }
                return e.Text.prototype.styleHas.call(this, t, i);
              },
              isEmptyStyles: function (t) {
                var e,
                  i,
                  n = 0,
                  r = t + 1,
                  s = !1,
                  o = this._styleMap[t],
                  a = this._styleMap[t + 1];
                for (var h in (o && ((t = o.line), (n = o.offset)),
                a && ((r = a.line), (s = r === t), (e = a.offset)),
                (i = "undefined" === typeof t ? this.styles : { line: this.styles[t] }),
                i))
                  for (var c in i[h]) if (c >= n && (!s || c < e)) for (var l in i[h][c]) return !1;
                return !0;
              },
              _getStyleDeclaration: function (t, e) {
                if (this._styleMap && !this.isWrapping) {
                  var i = this._styleMap[t];
                  if (!i) return null;
                  (t = i.line), (e = i.offset + e);
                }
                return this.callSuper("_getStyleDeclaration", t, e);
              },
              _setStyleDeclaration: function (t, e, i) {
                var n = this._styleMap[t];
                (t = n.line), (e = n.offset + e), (this.styles[t][e] = i);
              },
              _deleteStyleDeclaration: function (t, e) {
                var i = this._styleMap[t];
                (t = i.line), (e = i.offset + e), delete this.styles[t][e];
              },
              _getLineStyle: function (t) {
                var e = this._styleMap[t];
                return this.styles[e.line];
              },
              _setLineStyle: function (t, e) {
                var i = this._styleMap[t];
                this.styles[i.line] = e;
              },
              _deleteLineStyle: function (t) {
                var e = this._styleMap[t];
                delete this.styles[e.line];
              },
              _wrapText: function (t, e) {
                var i,
                  n = [];
                for (this.isWrapping = !0, i = 0; i < t.length; i++)
                  n = n.concat(this._wrapLine(t[i], i, e));
                return (this.isWrapping = !1), n;
              },
              _measureWord: function (t, e, i) {
                var n,
                  r = 0,
                  s = !0;
                i = i || 0;
                for (var o = 0, a = t.length; o < a; o++) {
                  var h = this._getGraphemeBox(t[o], e, o + i, n, s);
                  (r += h.kernedWidth), (n = t[o]);
                }
                return r;
              },
              _wrapLine: function (t, i, n, r) {
                var s = 0,
                  o = this.splitByGrapheme,
                  a = [],
                  h = [],
                  c = o ? e.util.string.graphemeSplit(t) : t.split(this._wordJoiners),
                  l = "",
                  u = 0,
                  f = o ? "" : " ",
                  d = 0,
                  g = 0,
                  p = 0,
                  m = !0,
                  v = o ? 0 : this._getWidthOfCharSpacing();
                r = r || 0;
                n -= r;
                for (var _ = 0; _ < c.length; _++)
                  (l = e.util.string.graphemeSplit(c[_])),
                    (d = this._measureWord(l, i, u)),
                    (u += l.length),
                    (s += g + d - v),
                    s >= n && !m ? (a.push(h), (h = []), (s = d), (m = !0)) : (s += v),
                    m || o || h.push(f),
                    (h = h.concat(l)),
                    (g = this._measureWord([f], i, u)),
                    u++,
                    (m = !1),
                    d > p && (p = d);
                return (
                  _ && a.push(h),
                  p + r > this.dynamicMinWidth && (this.dynamicMinWidth = p - v + r),
                  a
                );
              },
              isEndOfWrapping: function (t) {
                return (
                  !this._styleMap[t + 1] || this._styleMap[t + 1].line !== this._styleMap[t].line
                );
              },
              _splitTextIntoLines: function (t) {
                for (
                  var i = e.Text.prototype._splitTextIntoLines.call(this, t),
                    n = this._wrapText(i.lines, this.width),
                    r = new Array(n.length),
                    s = 0;
                  s < n.length;
                  s++
                )
                  r[s] = n[s].join("");
                return (i.lines = r), (i.graphemeLines = n), i;
              },
              getMinWidth: function () {
                return Math.max(this.minWidth, this.dynamicMinWidth);
              },
              toObject: function (t) {
                return this.callSuper("toObject", ["minWidth", "splitByGrapheme"].concat(t));
              },
            })),
              (e.Textbox.fromObject = function (t, i) {
                return e.Object._fromObject("Textbox", t, i, "text");
              });
          })(e),
          (function () {
            var t = n.Canvas.prototype._setObjectScale;
            (n.Canvas.prototype._setObjectScale = function (e, i, r, s, o, a, h) {
              var c,
                l = i.target,
                u = (e.x * l.scaleX) / h.x,
                f = (e.y * l.scaleY) / h.y;
              if (!("x" === o && l instanceof n.Textbox))
                return t.call(n.Canvas.prototype, e, i, r, s, o, a, h);
              var d = l._getTransformedDimensions().x,
                g = l.width * (e.x / d);
              return (
                (i.newScaleX = u),
                (i.newScaleY = f),
                g >= l.getMinWidth() ? ((c = g !== l.width), l.set("width", g), c) : void 0
              );
            }),
              n.util.object.extend(n.Textbox.prototype, {
                _removeExtraneousStyles: function () {
                  for (var t in this._styleMap)
                    this._textLines[t] || delete this.styles[this._styleMap[t].line];
                },
              });
          })();
      }.call(this, i(46).Buffer));
    },
    1425: function (t, e, i) {
      "use strict";
      i.d(e, "a", function () {
        return r;
      });
      var n = i(1417);
      function r(t) {
        (t._updateCacheCanvas = function () {
          var t = this.canvas;
          if (this.noScaleCache && t && t._currentTransform) {
            var e = t._currentTransform.target,
              i = t._currentTransform.action;
            if (this === e && i.slice && "scale" === i.slice(0, 5)) return !1;
          }
          var r,
            s,
            o = this._cacheCanvas,
            a = this._limitCacheSize(this._getCacheCanvasDimensions()),
            h = n["fabric"].minCacheSideLimit,
            c = a.width,
            l = a.height,
            u = a.zoomX,
            f = a.zoomY,
            d = c !== this.cacheWidth || l !== this.cacheHeight,
            g = this.zoomX !== u || this.zoomY !== f,
            p = d || g,
            m = 0,
            v = 0,
            _ = !1;
          if (d) {
            var y = this._cacheCanvas.width,
              b = this._cacheCanvas.height,
              x = c > y || l > b,
              C = (c < 0.9 * y || l < 0.9 * b) && y > h && b > h;
            (_ = x || C), x && !a.capped && (c > h || l > h) && ((m = 0.1 * c), (v = 0.1 * l));
          }
          return (
            (this._cacheMatrix = this._cacheMatrix || [1, 0, 0, 1, 0, 0]),
            !!p &&
              ((this._cacheMatrix = [1, 0, 0, 1, 0, 0]),
              _
                ? ((o.width = Math.ceil(c + m)), (o.height = Math.ceil(l + v)))
                : this._cacheContext.clearRect(0, 0, o.width, o.height),
              (r = a.x * u),
              (s = a.y * f),
              (this.cacheTranslationX = Math.round((o.width - r) / 2)),
              (this.cacheTranslationY = Math.round((o.height - s) / 2)),
              (this.cacheWidth = c),
              (this.cacheHeight = l),
              (this._cacheMatrix = n["fabric"].util.multiplyTransformMatrices(this._cacheMatrix, [
                1,
                0,
                0,
                1,
                this.cacheTranslationX,
                this.cacheTranslationY,
              ])),
              (this._cacheMatrix = n["fabric"].util.multiplyTransformMatrices(this._cacheMatrix, [
                u,
                0,
                0,
                f,
                0,
                0,
              ])),
              (this.zoomX = u),
              (this.zoomY = f),
              !0)
          );
        }),
          (t.calcOwnMatrix = function () {
            var t = this.transformMatrixKey(!0),
              e = this.ownMatrixCache || (this.ownMatrixCache = {});
            if (e.key === t) return e.value;
            var i = [1, 0, 0, 1, this.left, this.top],
              r = this._calcDimensionsTransformMatrix(this.skewX, this.skewY, !0);
            return (
              (i = n["fabric"].util.multiplyTransformMatrices(i, r)), (e.key = t), (e.value = i), i
            );
          }),
          (t.transform = function () {
            var t;
            return (
              (t =
                this.group && !this.group._transformDone
                  ? this.calcTransformMatrix()
                  : this.calcOwnMatrix()),
              t.slice(0)
            );
          }),
          (t.render = function (t, e) {
            if (
              !this.isNotVisible() &&
              (!this.canvas || !this.canvas.skipOffscreen || this.group || this.isOnScreen())
            ) {
              t.save(), this._setupCompositeOperation(t), this.drawSelectionBackground(t);
              var i = this.transform(t);
              this._setOpacity(t),
                this._setShadow(t, this),
                this.transformMatrix && t.transform.apply(t, this.transformMatrix),
                (i = n["fabric"].util.multiplyTransformMatrices(e, i)),
                this.clipTo && n["fabric"].util.clipContext(this, t),
                this.shouldCache()
                  ? (this.renderCache(), this.drawCacheOnCanvas(t, i))
                  : (this._removeCacheCanvas(),
                    (this.dirty = !1),
                    this.drawObject(t, null, i),
                    this.objectCaching &&
                      this.statefullCache &&
                      this.saveState({ propertySet: "cacheProperties" })),
                this.clipTo && t.restore(),
                t.restore();
            }
          }),
          (t.isCacheDirty = function (t) {
            if (this.isNotVisible()) return !1;
            if (this._cacheCanvas && !t && this._updateCacheCanvas()) return !0;
            if (
              this.dirty ||
              (this.clipPath && this.clipPath.absolutePositioned) ||
              (this.statefullCache && this.hasStateChanged("cacheProperties"))
            ) {
              if (this._cacheCanvas && !t) {
                var e = this.cacheWidth / this.zoomX,
                  i = this.cacheHeight / this.zoomY;
                this._cacheContext.clearRect(0, 0, e, i);
              }
              return !0;
            }
            return !1;
          }),
          (t.renderCache = function (t) {
            (t = t || {}),
              this._cacheCanvas || this._createCacheCanvas(),
              this.isCacheDirty() &&
                (this.statefullCache && this.saveState({ propertySet: "cacheProperties" }),
                this.drawObject(this._cacheContext, t.forClipping, this._cacheMatrix),
                (this.dirty = !1));
          }),
          (t.drawObject = function (t, e, i) {
            var n = this.fill,
              r = this.stroke;
            e
              ? ((this.fill = "black"), (this.stroke = ""), this._setClippingProperties(t))
              : (this._renderBackground(t),
                this._setStrokeStyles(t, this),
                this._setFillStyles(t, this)),
              this._render(t, i),
              this._drawClipPath(t, i),
              (this.fill = n),
              (this.stroke = r);
          }),
          (t.drawCacheOnCanvas = function (t, e) {
            var i = n["fabric"].util.multiplyTransformMatrices(e, [
                1 / this.zoomX,
                0,
                0,
                1 / this.zoomY,
                0,
                0,
              ]),
              r = n["fabric"].util.transformPoint(
                { x: -this.cacheTranslationX, y: -this.cacheTranslationY },
                i,
                !1
              ),
              s = this._cacheCanvas.width * Math.hypot(i[0], i[1]),
              o = this._cacheCanvas.height * Math.hypot(i[2], i[3]);
            t.drawImage(this._cacheCanvas, r.x, r.y, s, o);
          }),
          (t._drawClipPath = function (t, e) {
            var i = this.clipPath;
            i &&
              ((i.canvas = this.canvas),
              i.shouldCache(),
              (i._transformDone = !0),
              this.drawClipPathOnCache(t, e));
          }),
          (t.drawClipPathOnCache = function (t, e) {
            var i = this.clipPath;
            if (
              (t.save(),
              (t.fillStyle = "#000"),
              i.inverted
                ? (t.globalCompositeOperation = "destination-out")
                : (t.globalCompositeOperation = "destination-in"),
              i.absolutePositioned)
            ) {
              var r = n["fabric"].util.invertTransform(this.calcTransformMatrix());
              e = n["fabric"].util.multiplyTransformMatrices(e, r);
            }
            var s = i.calcOwnMatrix();
            (e = n["fabric"].util.multiplyTransformMatrices(e, s)), i._render(t, e), t.restore();
          }),
          (t.containsPoint = function (t, e, i, n, r) {
            void 0 === r && (r = 0);
            var s = n ? this.calcCoords(i) : i ? this.aCoords : this.oCoords;
            (s = {
              tl: { x: s.tl.x - r, y: s.tl.y - r },
              tr: { x: s.tr.x + r, y: s.tr.y - r },
              bl: { x: s.bl.x - r, y: s.bl.y + r },
              br: { x: s.br.x + r, y: s.br.y + r },
            }),
              (e = e || this._getImageLines(s));
            var o = this._findCrossPoints(t, e);
            return 0 !== o && o % 2 === 1;
          }),
          (t.calcCoords = function (t) {
            var e = this._calcRotateMatrix(),
              i =
                this.sizeUniform && !t
                  ? [1, 0, 0, 1, this.left, this.top]
                  : this._calcTranslateMatrix(),
              r = n["fabric"].util.multiplyTransformMatrices(i, e),
              s = this.getViewportTransform(),
              o = t ? r : n["fabric"].util.multiplyTransformMatrices(s, r),
              a = this._getTransformedDimensions(),
              h = a.x / 2,
              c = a.y / 2;
            this.sizeUniform &&
              !t &&
              (this.uniformOffset &&
                ((o[4] += this.width / 2 + this.uniformOffset.x),
                (o[5] += this.height / 2 + this.uniformOffset.y)),
              (o = n["fabric"].util.multiplyTransformMatrices(o, [
                1 / s[0],
                0,
                0,
                1 / s[3],
                0,
                0,
              ])));
            var l,
              u,
              f,
              d,
              g,
              p = n["fabric"].util.transformPoint({ x: -h, y: -c }, o),
              m = n["fabric"].util.transformPoint({ x: h, y: -c }, o),
              v = n["fabric"].util.transformPoint({ x: -h, y: c }, o),
              _ = n["fabric"].util.transformPoint({ x: h, y: c }, o);
            if (!t) {
              var y = this.padding,
                b = n["fabric"].util.degreesToRadians(this.angle),
                x = n["fabric"].util.cos(b),
                C = n["fabric"].util.sin(b),
                w = x * y,
                S = C * y,
                T = w + S,
                O = w - S;
              y &&
                ((p.x -= O),
                (p.y -= T),
                (m.x += T),
                (m.y -= O),
                (v.x -= T),
                (v.y += O),
                (_.x += O),
                (_.y += T)),
                (l = new n["fabric"].Point((p.x + v.x) / 2, (p.y + v.y) / 2)),
                (u = new n["fabric"].Point((m.x + p.x) / 2, (m.y + p.y) / 2)),
                (f = new n["fabric"].Point((_.x + m.x) / 2, (_.y + m.y) / 2)),
                (d = new n["fabric"].Point((_.x + v.x) / 2, (_.y + v.y) / 2)),
                (g = new n["fabric"].Point(
                  u.x + C * this.rotatingPointOffset,
                  u.y - x * this.rotatingPointOffset
                ));
            }
            var k = { tl: p, tr: m, br: _, bl: v };
            return t || ((k.ml = l), (k.mt = u), (k.mr = f), (k.mb = d), (k.mtr = g)), k;
          });
      }
    },
    1454: function (t, e, i) {},
    1455: function (t, e, i) {},
    1456: function (t, e, i) {
      "use strict";
      i.d(e, "a", function () {
        return n;
      });
      var n = {
        IMAGE_MOVED: "image.moved",
        IMAGE_IMPORTED: "image.imported",
        IMAGE_RESIZED: "image.resized",
        EDITOR_ZOOMED: "editor.zoomed",
        EDITOR_WHEEL_ZOOMED: "editor.wheel-zoomed",
        EDITOR_RESIZED: "editor.resized",
      };
    },
    1540: function (t, e, i) {
      "use strict";
      i(1454);
    },
    1541: function (t, e, i) {
      "use strict";
      function n(t, e, i, n) {
        var r = t / e,
          s = i / n;
        return r > s ? ((e = n), (t = n * r)) : ((t = i), (e = i / r)), [t, e];
      }
      function r(t, e, i, n) {
        var r = t / e,
          s = i / n;
        return r > s ? ((t = i), (e = i / r)) : ((e = n), (t = n * r)), [t, e];
      }
      i.d(e, "b", function () {
        return n;
      }),
        i.d(e, "a", function () {
          return r;
        });
    },
    1542: function (t, e, i) {
      "use strict";
      i(1455);
    },
    1543: function (t, e, i) {
      "use strict";
      function n(t, e, i) {
        return (
          void 0 === e && (e = "image/png"),
          void 0 === i && (i = 1),
          new Promise(function (n, r) {
            t.toBlob(
              function (t) {
                t ? n(t) : r("cannot covert this canvas to Blob data");
              },
              e,
              i
            );
          })
        );
      }
      i.d(e, "a", function () {
        return n;
      });
    },
    1544: function (t, e, i) {
      "use strict";
      i.d(e, "a", function () {
        return s;
      }),
        i.d(e, "b", function () {
          return o;
        });
      var n = i(1475),
        r = i(1521);
      function s(t) {
        let e = 0,
          i = 0;
        if (
          (t instanceof HTMLImageElement && ((e = t.naturalWidth), (i = t.naturalHeight)),
          t instanceof HTMLCanvasElement && ((e = t.width), (i = t.height)),
          !e || !i)
        )
          throw new Error("传入图片有误");
        const { canvas: r, ctx: s } = Object(n["a"])(e, i);
        return s.drawImage(t, 0, 0), r;
      }
      async function o(t) {
        return s(await Object(r["b"])(t));
      }
    },
    1545: function (t, e, i) {
      "use strict";
      i.d(e, "a", function () {
        return r;
      });
      var n = i(1417),
        r = function (t, e) {
          var i = new n["fabric"].Canvas(t, e);
          return (
            (i.zoomToPoint = function (t, e) {
              var i = t,
                r = this.viewportTransform.slice(0);
              (t = n["fabric"].util.transformPoint(
                t,
                n["fabric"].util.invertTransform(this.viewportTransform)
              )),
                (r[0] = e),
                (r[3] = e);
              var s = n["fabric"].util.transformPoint(t, r);
              return (r[4] += i.x - s.x), (r[5] += i.y - s.y), this.setViewportTransform(r);
            }),
            (i.renderCanvas = function (t, e) {
              var r = this.viewportTransform,
                s = this.clipPath;
              return (
                this.cancelRequestedRender(),
                this.calcViewportBoundaries(),
                this.clearContext(t),
                this.fire("before:render", { ctx: t }),
                this.clipTo && n["fabric"].util.clipContext(this, t),
                this._renderBackground(t),
                t.save(),
                this._renderObjects(t, e, r.slice(0)),
                t.restore(),
                !this.controlsAboveOverlay && this.interactive && this.drawControls(t),
                this.clipTo && t.restore(),
                s &&
                  ((s.canvas = this),
                  s.shouldCache(),
                  (s._transformDone = !0),
                  s.renderCache({ forClipping: !0 }),
                  this.drawClipPathOnCanvas(t)),
                this._renderOverlay(t),
                this.controlsAboveOverlay && this.interactive && this.drawControls(t),
                this.fire("after:render", { ctx: t }),
                i
              );
            }),
            (i._renderObjects = function (t, e, i) {
              var n, r;
              for (n = 0, r = e.length; n < r; ++n) (e[n] && e[n]).render(t, i);
            }),
            i
          );
        };
    },
    1546: function (t, e, i) {
      "use strict";
      i.d(e, "a", function () {
        return s;
      });
      var n = i(1417),
        r = i(1425),
        s = function (t, e) {
          var i = new n["fabric"].Image(t, e);
          return (
            Object(r["a"])(i),
            (i.calcRotateMatrix = function (t) {
              var e = n["fabric"].util.transformPoint(
                  { x: this.rotateOffsetX / 2 || 0, y: this.rotateOffsetY / 2 || 0 },
                  t
                ),
                i = n["fabric"].util.multiplyTransformMatrices(
                  [1, 0, 0, 1, e.x, e.y],
                  this._calcRotateMatrix()
                );
              return (
                (i = n["fabric"].util.multiplyTransformMatrices(i, [1, 0, 0, 1, -e.x, -e.y])), i
              );
            }),
            (i._render = function (t, e) {
              this._imgRenderingMatrix = e;
              var i = this.calcRotateMatrix(e);
              t.transform.apply(t, i),
                !0 !== this.isMoving &&
                  this.resizeFilter &&
                  this._needsResize() &&
                  this.applyResizeFilters(),
                this._stroke(t),
                this._renderPaintInOrder(t);
            }),
            (i._stroke = function (t) {
              if (this.stroke && 0 !== this.strokeWidth) {
                var e = this._imgRenderingMatrix,
                  i = n["fabric"].util.transformPoint({ x: 0, y: 0 }, e),
                  r = this.width * e[0],
                  s = this.height * e[0];
                t.beginPath(),
                  t.moveTo(i.x, i.y),
                  t.lineTo(i.x + r, i.y),
                  t.lineTo(i.x + r, i.y + s),
                  t.lineTo(i.x, i.y + s),
                  t.lineTo(i.x, i.y),
                  t.closePath();
              }
            }),
            (i._renderFill = function (t) {
              var e = this._imgRenderingMatrix,
                i = this._element,
                r = this.width,
                s = this.height,
                o = Math.min(i.naturalWidth || i.width, r * this._filterScalingX),
                a = Math.min(i.naturalHeight || i.height, s * this._filterScalingY),
                h = 0,
                c = 0,
                l = Math.max(0, this.cropX * this._filterScalingX),
                u = Math.max(0, this.cropY * this._filterScalingY),
                f = n["fabric"].util.transformPoint({ x: h, y: c }, e),
                d = e[0];
              i && t.drawImage(i, l, u, o, a, f.x, f.y, r * d, s * d);
            }),
            i
          );
        };
    },
    1573: function (t, e, i) {
      "use strict";
      i.d(e, "a", function () {
        return b;
      });
      var n = i(1417);
      function r(t) {
        return t.getContext("2d");
      }
      function s(t, e, i) {
        void 0 === i && (i = !1);
        var n = document.createElement("canvas"),
          s = r(n);
        return (
          "number" === typeof t
            ? ((n.width = t), (n.height = e), (i = i || !1))
            : (i = "boolean" === typeof t && t),
          (s.imageSmoothingEnabled = i),
          { canvas: n, ctx: s }
        );
      }
      function o(t, e) {
        var i = s(20, 20),
          n = i.canvas,
          r = i.ctx;
        return (
          (r.fillStyle = t),
          r.fillRect(0, 0, 10, 10),
          r.fillRect(10, 10, 10, 10),
          (r.fillStyle = e),
          r.fillRect(10, 0, 10, 10),
          r.fillRect(0, 10, 10, 10),
          n
        );
      }
      var a = {
        CubicEaseIn: function (t, e, i, n) {
          return i * (t /= n) * t * t + e;
        },
        CubicEaseOut: function (t, e, i, n) {
          return i * ((t = t / n - 1) * t * t + 1) + e;
        },
        CubicEaseInOut: function (t, e, i, n) {
          return (t /= n / 2) < 1 ? (i / 2) * t * t * t + e : (i / 2) * ((t -= 2) * t * t + 2) + e;
        },
        BounceEaseIn: function (t, e, i, n) {
          return i - a.BounceEaseOut(n - t, 0, i, n) + e;
        },
        BounceEaseOut: function (t, e, i, n) {
          return (t /= n) < 1 / 2.75
            ? i * (7.5625 * t * t) + e
            : t < 2 / 2.75
            ? i * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + e
            : t < 2.5 / 2.75
            ? i * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + e
            : i * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + e;
        },
        BounceEaseInOut: function (t, e, i, n) {
          return t < n / 2
            ? 0.5 * a.BounceEaseIn(2 * t, 0, i, n) + e
            : 0.5 * a.BounceEaseOut(2 * t - n, 0, i, n) + 0.5 * i + e;
        },
      };
      function h(t, e, i, n) {
        var r = i - e;
        return function (i) {
          return a[t](i, e, r, n);
        };
      }
      var c = {};
      function l(t, e) {
        if ((void 0 === e && (e = !1), e && c[t])) return c[t];
        var i = new Promise(function (i, n) {
          var r = new Image();
          (r.onload = function () {
            delete r.onload, i(r);
          }),
            (r.onerror = function (i) {
              e && delete c[t], delete r.onerror, n(i);
            }),
            (r.crossOrigin = "crossOrigin"),
            (r.src = t);
        });
        return e && (c[t] = i), i;
      }
      var u = function () {
        return (
          (u =
            Object.assign ||
            function (t) {
              for (var e, i = 1, n = arguments.length; i < n; i++)
                for (var r in ((e = arguments[i]), e))
                  Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
              return t;
            }),
          u.apply(this, arguments)
        );
      };
      function f(t) {
        var e = [];
        if (t.shadow) {
          var i = t.shadow,
            n = i.offsetX,
            r = i.offsetY,
            s = i.blur,
            o = -n + s,
            a = -r + s;
          e.push({ right: n + s, bottom: r + s, left: o < 0 ? 0 : o, top: a < 0 ? 0 : a });
        }
        if (t.outline) {
          var h = [].concat(t.outline)[0];
          if (h) {
            var c = h.width;
            e.push({ left: c, right: c, top: c, bottom: c });
          }
        }
        var l = { left: 0, right: 0, top: 0, bottom: 0 };
        return e.length
          ? e.reduce(function (t, e) {
              return (
                Object.keys(t).forEach(function (i) {
                  t[i] = Math.max(t[i], e[i]);
                }),
                t
              );
            }, u({}, l))
          : l;
      }
      var d = (function () {
          function t() {
            (this.eventHandlers = {}), (this.onceEventHandlers = {});
          }
          return (
            (t.prototype.emit = function (t) {
              for (var e = [], i = 1; i < arguments.length; i++) e[i - 1] = arguments[i];
              var n = this.eventHandlers[t],
                r = this.onceEventHandlers[t];
              if (n && n.length > 0)
                for (var s = 0, o = n; s < o.length; s++) {
                  var a = o[s];
                  a.apply(void 0, e);
                }
              if (r && r.length > 0)
                for (var h = 0, c = r; h < c.length; h++) {
                  a = c[h];
                  a.apply(void 0, e), this._removeHandlers(r, a);
                }
            }),
            (t.prototype.get = function (t) {
              return this.eventHandlers[t] || [];
            }),
            (t.prototype.on = function (t, e) {
              var i = this.eventHandlers[t] || [];
              (this.eventHandlers[t] = i), i.push(e);
            }),
            (t.prototype.once = function (t, e) {
              var i = this.onceEventHandlers[t] || [];
              (this.onceEventHandlers[t] = i), i.push(e);
            }),
            (t.prototype.off = function (t, e) {
              var i = this.eventHandlers[t],
                n = this.onceEventHandlers[t];
              i && e ? this._removeHandlers(i, e) : i && (this.eventHandlers[t] = []),
                n && e ? this._removeHandlers(n, e) : n && (this.onceEventHandlers[t] = []);
            }),
            (t.prototype._removeHandlers = function (t, e) {
              var i = t.indexOf(e);
              -1 !== i && t.splice(i, 1);
            }),
            t
          );
        })(),
        g = i(1456),
        p = i(1545),
        m = i(1546),
        v = function () {
          return (
            (v =
              Object.assign ||
              function (t) {
                for (var e, i = 1, n = arguments.length; i < n; i++)
                  for (var r in ((e = arguments[i]), e))
                    Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
                return t;
              }),
            v.apply(this, arguments)
          );
        },
        _ = function (t, e, i, n) {
          function r(t) {
            return t instanceof i
              ? t
              : new i(function (e) {
                  e(t);
                });
          }
          return new (i || (i = Promise))(function (i, s) {
            function o(t) {
              try {
                h(n.next(t));
              } catch (e) {
                s(e);
              }
            }
            function a(t) {
              try {
                h(n["throw"](t));
              } catch (e) {
                s(e);
              }
            }
            function h(t) {
              t.done ? i(t.value) : r(t.value).then(o, a);
            }
            h((n = n.apply(t, e || [])).next());
          });
        },
        y = function (t, e) {
          var i,
            n,
            r,
            s,
            o = {
              label: 0,
              sent: function () {
                if (1 & r[0]) throw r[1];
                return r[1];
              },
              trys: [],
              ops: [],
            };
          return (
            (s = { next: a(0), throw: a(1), return: a(2) }),
            "function" === typeof Symbol &&
              (s[Symbol.iterator] = function () {
                return this;
              }),
            s
          );
          function a(t) {
            return function (e) {
              return h([t, e]);
            };
          }
          function h(s) {
            if (i) throw new TypeError("Generator is already executing.");
            while (o)
              try {
                if (
                  ((i = 1),
                  n &&
                    (r =
                      2 & s[0]
                        ? n["return"]
                        : s[0]
                        ? n["throw"] || ((r = n["return"]) && r.call(n), 0)
                        : n.next) &&
                    !(r = r.call(n, s[1])).done)
                )
                  return r;
                switch (((n = 0), r && (s = [2 & s[0], r.value]), s[0])) {
                  case 0:
                  case 1:
                    r = s;
                    break;
                  case 4:
                    return o.label++, { value: s[1], done: !1 };
                  case 5:
                    o.label++, (n = s[1]), (s = [0]);
                    continue;
                  case 7:
                    (s = o.ops.pop()), o.trys.pop();
                    continue;
                  default:
                    if (
                      ((r = o.trys),
                      !(r = r.length > 0 && r[r.length - 1]) && (6 === s[0] || 2 === s[0]))
                    ) {
                      o = 0;
                      continue;
                    }
                    if (3 === s[0] && (!r || (s[1] > r[0] && s[1] < r[3]))) {
                      o.label = s[1];
                      break;
                    }
                    if (6 === s[0] && o.label < r[1]) {
                      (o.label = r[1]), (r = s);
                      break;
                    }
                    if (r && o.label < r[2]) {
                      (o.label = r[2]), o.ops.push(s);
                      break;
                    }
                    r[2] && o.ops.pop(), o.trys.pop();
                    continue;
                }
                s = e.call(t, o);
              } catch (a) {
                (s = [6, a]), (n = 0);
              } finally {
                i = r = 0;
              }
            if (5 & s[0]) throw s[1];
            return { value: s[0] ? s[1] : void 0, done: !0 };
          }
        };
      n["fabric"].Object.prototype.objectCaching = !1;
      var b = (function () {
        function t(t, e, i) {
          var r = this;
          if (
            (void 0 === e && (e = {}),
            void 0 === i && (i = []),
            (this.originFitZoom = 1),
            (this.plugins = {}),
            (this.currentPlugin = ""),
            (this.zoomLocked = !1),
            (this.pluginLocked = !1),
            (this._event = new d()),
            (this._renderImageId = 0),
            (this.renderOptions = {
              renderBackground: !0,
              fullEffect: !1,
              renderSize: { width: 0, height: 0 },
              imageBounding: { width: 0, height: 0, left: 0, top: 0 },
              rotate: 0,
            }),
            (this.backgroundRenderers = []),
            (this.effectRenderers = []),
            (this.globalRenderers = []),
            (this.stickObjects = []),
            "string" === typeof t && ((t = document.getElementById(t)), !t))
          )
            throw new Error("No canvas element correspond to this id.");
          var s = (this.options = this._mergeDefaultOptions(e)),
            a = !!t.parentElement;
          (this.ctx = new p["a"](t, {
            imageSmoothingEnabled: s.imageSmoothing,
            backgroundColor: e.background
              ? e.background
              : new n["fabric"].Pattern({
                  source: o(s.tileColor[0], s.tileColor[1]),
                  repeat: "repeat",
                }),
            selection: !1,
            defaultCursor: "",
            hoverCursor: "",
            skipTargetFind: !0,
            skipOffscreen: !1,
            renderOnAddRemove: !1,
          })),
            (this.el = a ? this.ctx.getSelectionElement() : t),
            this.ctx._setImageSmoothing(),
            this._initMouseEvent(),
            i.forEach(function (t) {
              r._registerPlugin(t);
            }),
            (this.pluginsList = i),
            e.defaultPlugin && this.usePlugin(e.defaultPlugin),
            e.scrollZoom && this._initScrollingZoom(e.centralZoom);
        }
        return (
          Object.defineProperty(t.prototype, "height", {
            get: function () {
              return this.ctx.getHeight();
            },
            enumerable: !1,
            configurable: !0,
          }),
          Object.defineProperty(t.prototype, "width", {
            get: function () {
              return this.ctx.getWidth();
            },
            enumerable: !1,
            configurable: !0,
          }),
          Object.defineProperty(t.prototype, "zoom", {
            get: function () {
              return this.ctx.getZoom();
            },
            enumerable: !1,
            configurable: !0,
          }),
          (t.prototype._initScrollingZoom = function (t) {
            var e = this,
              i = this.el,
              n = window.navigator.userAgent.toLowerCase(),
              r = n.includes("windows") && !n.includes("firefox") ? 2500 : 200;
            i.addEventListener(
              "wheel",
              function (i) {
                var n = i;
                n.preventDefault();
                var s = -n.deltaY / r,
                  o = e.zoom * (1 + (s / 2) * 0.4),
                  a = { x: 0, y: 0 };
                a = t ? { x: e.width / 2, y: e.height / 2 } : e.toCanvasCoord(i, !0);
                var h = e.setZoom(o, a);
                h && e._event.emit(g["a"].EDITOR_WHEEL_ZOOMED, i);
              },
              !1
            );
          }),
          (t.prototype._initMouseEvent = function () {
            var t = this,
              e = !1,
              i = {
                touchstart: function (t, e) {
                  var i = t.touches[0];
                  e.mousedown &&
                    e.mousedown({
                      clientX: i.clientX,
                      clientY: i.clientY,
                      pageX: i.pageX,
                      pageY: i.pageY,
                      screenX: i.screenX,
                      screenY: i.screenY,
                      touches: t.touches,
                    });
                },
                touchmove: function (t, e) {
                  var i = t.touches[0];
                  e.mousemove &&
                    e.mousemove({
                      clientX: i.clientX,
                      clientY: i.clientY,
                      pageX: i.pageX,
                      pageY: i.pageY,
                      screenX: i.screenX,
                      screenY: i.screenY,
                      touches: t.touches,
                    });
                },
                touchend: function (t, e) {
                  var i = t.changedTouches[0];
                  e.mouseup &&
                    e.mouseup({
                      clientX: i.clientX,
                      clientY: i.clientY,
                      pageX: i.pageX,
                      pageY: i.pageY,
                      screenX: i.screenX,
                      screenY: i.screenY,
                    });
                },
              },
              n = {
                mousedown: function (e, i) {
                  i.lockPlugin && t.lockPlugin(),
                    i.lockZoom && t.lockZoom(),
                    i.mousedown && i.mousedown(e);
                },
                mousemove: function (t, e) {
                  e.mousemove && e.mousemove(t);
                },
                mouseup: function (e, i) {
                  i.lockPlugin && t.unlockPlugin(),
                    i.lockZoom && t.unlockZoom(),
                    i.mouseup && i.mouseup(e);
                },
                click: function (t, e) {
                  e.click && e.click(t);
                },
                dblclick: function (t, e) {
                  e.dblclick && e.dblclick(t);
                },
                mouseleave: function (t, i) {
                  (e = !0), i.mouseleave && i.mouseleave(t);
                },
                mouseenter: function (t, i) {
                  (e = !1), i.mouseenter && i.mouseenter(t);
                },
                "document.mousemove": function (t, i) {
                  e && i.mousemoveoutside && i.mousemoveoutside(t);
                },
                "document.mouseup": function (i, n) {
                  e &&
                    (n.lockPlugin && t.unlockPlugin(),
                    n.lockZoom && t.unlockZoom(),
                    n.mouseupoutside && n.mouseupoutside(i));
                },
              },
              r = this.el;
            if (this.options.isMobile) {
              var s = function (e) {
                r.addEventListener(e, function (n) {
                  var r = t.plugins[t.currentPlugin];
                  r && r.invoke && i[e](n, r);
                });
              };
              for (var o in i) s(o);
            }
            var a = function (e) {
              if (e.includes("document")) {
                var i = e.split(".")[1];
                return (
                  document.addEventListener(
                    i,
                    function (i) {
                      var r = t.plugins[t.currentPlugin];
                      r && r.invoke && n[e](i, r);
                    },
                    !1
                  ),
                  "continue"
                );
              }
              r.addEventListener(
                e,
                function (i) {
                  var r = t.plugins[t.currentPlugin];
                  r && r.invoke && n[e](i, r);
                },
                !1
              );
            };
            for (var h in n) a(h);
          }),
          (t.prototype._mergeDefaultOptions = function (t) {
            return Object.assign(
              {
                imageSmoothing: !1,
                imageBorder: 0,
                imageBorderColor: "#000000",
                background: null,
                tileColor: ["#E4E7E9", "#F7FAFC"],
                defaultPlugin: "",
                scrollZoom: !0,
                maxZoom: 10,
                minZoom: 0.15,
                isMobile: !1,
              },
              t
            );
          }),
          (t.prototype._registerPlugin = function (t) {
            if (this.plugins[t.name])
              throw new Error(
                "The name of plugin has been taken or you are trying registered the same plugin twice."
              );
            t.install(this), (this.plugins[t.name] = t);
          }),
          (t.prototype.stopPlugin = function () {
            this.currentPlugin && this.plugins[this.currentPlugin].inactive(),
              (this.currentPlugin = "");
          }),
          (t.prototype.usePlugin = function (t) {
            for (var e, i = [], n = 1; n < arguments.length; n++) i[n - 1] = arguments[n];
            if (!this.pluginLocked) {
              if (!this.plugins[t]) throw new Error('The plugin "' + t + '" is not existed.');
              if (this.currentPlugin !== t)
                return (
                  this.currentPlugin && this.plugins[this.currentPlugin].inactive(),
                  (this.currentPlugin = t),
                  (e = this.plugins[t]).active.apply(e, i)
                );
            }
          }),
          (t.prototype.setCursor = function (t) {
            (this.el.style.cursor = t), (this.ctx.defaultCursor = t);
          }),
          (t.prototype.getRenderImageSize = function () {
            if (!this.instance) throw new Error("还未导入图片!");
            return { width: this.instance.width, height: this.instance.height };
          }),
          (t.prototype.getImageSize = function () {
            if (!this.source) throw new Error("还未导入图片!");
            return { width: this.source.width, height: this.source.height };
          }),
          (t.prototype.fitToContainer = function () {
            var t = this.ctx.wrapperEl.parentElement || this.el.parentElement;
            if (!t) throw new Error("The canvas has not been mounted.");
            var e = t.getBoundingClientRect(),
              i = e.width,
              n = e.height;
            this.setDimension({ width: i, height: n });
          }),
          (t.prototype.setDimension = function (t) {
            this.ctx.setDimensions(t), this._event.emit(g["a"].EDITOR_RESIZED);
          }),
          (t.prototype.setRenderSize = function (t, e) {
            if ((void 0 === e && (e = !1), !this.instance)) throw new Error("还未导入图片！");
            var i = this.renderOptions.renderSize;
            if (((this.renderOptions.renderSize = t), e)) {
              var n = this.instance;
              (n.left += (i.width - t.width) / 2),
                (n.top += (i.height - t.height) / 2),
                n.setCoords();
            }
            this._event.emit(g["a"].IMAGE_RESIZED, { width: t.width, height: t.height });
          }),
          (t.prototype.setImageRenderBounding = function (t) {
            var e = t.left,
              i = t.top,
              n = t.width,
              r = t.height;
            if (!this.source) throw new Error("还未导入图片！");
            var s = function (t) {
                return "number" === typeof t;
              },
              o = this.renderOptions.imageBounding;
            this.renderOptions.imageBounding = {
              left: s(e) ? e : o.left,
              top: s(i) ? i : o.top,
              width: s(n) ? n : o.width,
              height: s(r) ? r : o.height,
            };
          }),
          (t.prototype.setZoom = function (t, e) {
            if (this.zoomLocked) return !1;
            var i = this.options;
            if (
              (t > i.maxZoom && (t = i.maxZoom), t < i.minZoom && (t = i.minZoom), t === this.zoom)
            )
              return !1;
            var n = this.ctx;
            return this._setZoom(t, e || n.getVpCenter()), this.requestUpdateView(), this.zoom;
          }),
          (t.prototype.lockZoom = function () {
            this.zoomLocked = !0;
          }),
          (t.prototype.unlockZoom = function () {
            this.zoomLocked = !1;
          }),
          (t.prototype.lockPlugin = function () {
            this.pluginLocked = !0;
          }),
          (t.prototype.unlockPlugin = function () {
            this.pluginLocked = !1;
          }),
          (t.prototype.centerObject = function (t) {
            var e = this.ctx.getCenter();
            t.setPositionByOrigin(new n["fabric"].Point(e.left, e.top), "center", "center"),
              t.setCoords();
          }),
          (t.prototype.getCenterCoords = function (t, e) {
            var i;
            if ((void 0 === e && (e = !1), e)) {
              var n = this.ctx.getVpCenter();
              i = { left: n.x, top: n.y };
            } else i = this.ctx.getCenter();
            var r = t.translateToCenterPoint({ x: i.left, y: i.top }, "center", "center"),
              s = t.translateToOriginPoint(r, t.originX, t.originY);
            return s;
          }),
          (t.prototype.getFitMatrix = function (t, e) {
            void 0 === e && (e = 0);
            var i = t.aCoords || t.getCoords(!0, !0),
              r = this.getFitZoom(t, e);
            t === this.instance && (this.originFitZoom = r);
            var s = this.ctx.getCenter(),
              o = t.scaleX,
              a = t.scaleY,
              h = { x: i.tl.x + (t.width * o) / 2, y: i.tl.y + (t.height * a) / 2 },
              c = h.x - s.left * (1 / r),
              l = h.y - s.top * (1 / r);
            return n["fabric"].util.invertTransform([1 / r, 0, 0, 1 / r, c, l]);
          }),
          (t.prototype.getFitZoom = function (t, e) {
            void 0 === e && (e = 0);
            var i = t.width,
              n = t.height,
              r = this,
              s = r.width,
              o = r.height,
              a = (e * n) / (o - e),
              h = (e * i) / (s - e),
              c = o / (n + 2 * a),
              l = s / (i + 2 * h);
            return c < 1 || l < 1 ? Math.floor(100 * (c < l ? c : l)) / 100 : Math.min(c, l);
          }),
          (t.prototype.fitZoom = function (t, e) {
            void 0 === e && (e = 0);
            var i = this.ctx.getCenter(),
              n = { x: Math.floor(i.left + 0.5), y: Math.floor(i.top + 0.5) },
              r = this.getFitZoom(t, e);
            this.ctx.setViewportTransform([1, 0, 0, 1, 0, 0]), this.setZoom(r, n);
          }),
          (t.prototype.fitObject = function (t, e) {
            void 0 === e && (e = 0), this.fitZoom(t, e), this.centerObject(t);
          }),
          (t.prototype.fitImage = function (t) {
            if ((void 0 === t && (t = 0), !this.instance))
              throw new Error("There's no image to fit.");
            var e = this.getFitMatrix(this.instance, t);
            this.setViewportTransform(e);
          }),
          (t.prototype.animateFitImage = function (t, e) {
            if ((void 0 === t && (t = 0), void 0 === e && (e = 600), !this.instance))
              throw new Error("There's no image to fit.");
            var i = this,
              n = this.getFitMatrix(this.instance, t),
              r = this.ctx.viewportTransform.slice(0),
              s = [
                [r[0], n[0]],
                [r[3], n[3]],
                [r[4], n[4]],
                [r[5], n[5]],
              ].map(function (t) {
                return h("CubicEaseInOut", t[0], t[1], e);
              }),
              o = 16;
            requestAnimationFrame(function t() {
              o >= 600
                ? (i.setViewportTransform(n), i.requestUpdateView())
                : (i.ctx.setViewportTransform([s[0](o), 0, 0, s[1](o), s[2](o), s[3](o)]),
                  i.updateView(),
                  (o += 16),
                  requestAnimationFrame(t));
            });
          }),
          (t.prototype._getObjectsBoundary = function (t) {
            for (
              var e = { x: Number.POSITIVE_INFINITY, y: Number.POSITIVE_INFINITY },
                i = { x: Number.NEGATIVE_INFINITY, y: Number.NEGATIVE_INFINITY },
                n = this.ctx.getObjects(),
                r = 0,
                s = n;
              r < s.length;
              r++
            ) {
              var o = s[r];
              if (o.visible) {
                var a = o === this.instance && t ? t : o.aCoords || o.getCoords(!0, !0),
                  h = a.tl,
                  c = a.br;
                e.x > h.x && (e.x = h.x),
                  e.y > h.y && (e.y = h.y),
                  i.x < c.x && (i.x = c.x),
                  i.y < c.y && (i.y = c.y);
              }
            }
            return { tl: e, br: i };
          }),
          (t.prototype._toCenteredMatrix = function (t, e) {
            var i = n["fabric"].util.invertTransform(t),
              r = n["fabric"].util.transformPoint({ x: this.width / 2, y: this.height / 2 }, i),
              s = e || this._getObjectsBoundary(),
              o = s.tl,
              a = s.br;
            return (
              a.x < r.x && (i[4] = a.x - (this.width / 2) * i[0]),
              a.y < r.y && (i[5] = a.y - (this.height / 2) * i[3]),
              o.x > r.x && (i[4] = o.x - (this.width / 2) * i[0]),
              o.y > r.y && (i[5] = o.y - (this.height / 2) * i[3]),
              n["fabric"].util.invertTransform(i)
            );
          }),
          (t.prototype._setZoom = function (t, e) {
            var i = this.ctx.viewportTransform.slice(0);
            (i[0] = t), (i[3] = t);
            var r = e,
              s = n["fabric"].util.transformPoint(
                e,
                n["fabric"].util.invertTransform(this.ctx.viewportTransform)
              ),
              o = n["fabric"].util.transformPoint(s, i);
            (i[4] += r.x - o.x),
              (i[5] += r.y - o.y),
              (i = this._toCenteredMatrix(i)),
              this.setViewportTransform(i);
          }),
          (t.prototype._getCenterdOffset = function (t, e) {
            if (!this.instance) throw new Error("No Image has been imported yet");
            var i = this.ctx.getVpCenter(),
              n = i.x,
              r = i.y,
              s = this.instance,
              o = s.width,
              a = s.height,
              h = Math.min(n, Math.max(n - o, t)),
              c = Math.min(r, Math.max(r - a, e)),
              l = h - t,
              u = c - e;
            return { offsetX: l, offsetY: u };
          }),
          (t.prototype.setViewportTransform = function (t) {
            this.ctx.setViewportTransform(t), this._event.emit(g["a"].EDITOR_ZOOMED, t[0]);
          }),
          (t.prototype.panEditor = function (t, e) {
            var i = this.ctx,
              n = i.viewportTransform.slice(0);
            (n[4] += t),
              (n[5] += e),
              (n = this._toCenteredMatrix(n)),
              this.setViewportTransform(n),
              this.requestUpdateView();
          }),
          (t.prototype.stickWithImg = function () {
            for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
            for (var i = 0, n = t; i < n.length; i++) {
              var r = n[i];
              this.stickObjects.push(r);
            }
          }),
          (t.prototype.unstick = function () {
            for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
            var i = [];
            t.forEach(function (t) {
              t.markedDelete = !0;
            }),
              this.stickObjects.forEach(function (t) {
                t.markedDelete || i.push(t);
              }),
              t.forEach(function (t) {
                delete t.markedDelete;
              }),
              (this.stickObjects = i);
          }),
          (t.prototype.centerImage = function () {
            if (!this.instance) throw new Error("No image exist yet");
            var t = this.instance,
              e = t.left,
              i = t.top,
              n = this.getCenterCoords(t, !0);
            this.setImagePositionByOffset(n.x - e, n.y - i);
          }),
          (t.prototype.setImagePositionByOffset = function (t, e) {
            if (!this.instance) throw new Error("No image exist yet");
            if (t || e) {
              (this.instance.left += t),
                (this.instance.top += e),
                (this.instance.dirty = !0),
                this.instance.setCoords();
              for (var i = 0, n = this.stickObjects; i < n.length; i++) {
                var r = n[i];
                (r.left += t), (r.top += e), (r.dirty = !0), r.setCoords();
              }
              this._event.emit(g["a"].IMAGE_MOVED, t, e), this.requestUpdateView();
            }
          }),
          (t.prototype.toCanvasCoord = function (t, e) {
            return void 0 === e && (e = !1), this.ctx.getPointer(t, e);
          }),
          (t.prototype.toRoundedCanvasCoord = function (t, e) {
            void 0 === e && (e = !1);
            var i = this.ctx.getPointer(t, e);
            return { x: Math.round(i.x), y: Math.round(i.y) };
          }),
          (t.prototype.toImageCoord = function (t) {
            if (!this.instance) throw new Error("No image existed yet");
            return this.instance.getLocalPointer(t);
          }),
          (t.prototype.importImage = function (t) {
            return _(this, void 0, void 0, function () {
              var e, i, n, r, o, a, h, c;
              return y(this, function (u) {
                switch (u.label) {
                  case 0:
                    return "string" !== typeof t ? [3, 2] : [4, l(t)];
                  case 1:
                    (t = u.sent()), (u.label = 2);
                  case 2:
                    return (
                      t instanceof HTMLImageElement &&
                        ((e = s(t.width, t.height)),
                        (i = e.canvas),
                        (n = e.ctx),
                        n.drawImage(t, 0, 0),
                        (t = i)),
                      (r = s(t.width, t.height)),
                      (o = r.canvas),
                      (a = r.ctx),
                      a.drawImage(t, 0, 0),
                      (h = o),
                      (this.renderOptions.renderSize = { width: t.width, height: t.height }),
                      (this.renderOptions.imageBounding = {
                        left: 0,
                        top: 0,
                        width: t.width,
                        height: t.height,
                      }),
                      this.instance
                        ? (this.instance.setElement(h),
                          (this.instance.width = t.width),
                          (this.instance.height = t.height),
                          (this.instance.dirty = !0),
                          this.requestUpdateView())
                        : ((c = new m["a"](h)),
                          this.options.imageBorder &&
                            ((c.strokeWidth = this.options.imageBorder),
                            (c.stroke = this.options.imageBorderColor)),
                          (this.instance = c),
                          this.ctx.add(c)),
                      (this.source = t),
                      (this.rendered = h),
                      this._event.emit(g["a"].IMAGE_IMPORTED, t),
                      [2]
                    );
                }
              });
            });
          }),
          (t.prototype.imageContainsPoint = function (t) {
            if (!this.instance) throw new Error("还未导入图片");
            var e = t instanceof Event ? this.ctx.getPointer(t, !0) : t;
            return this.instance.containsPoint(e);
          }),
          (t.prototype.registerEffectRenderer = function (t) {
            this.effectRenderers.push(t);
          }),
          (t.prototype.registerBackgroundRenderer = function (t) {
            this.backgroundRenderers.push(t);
          }),
          (t.prototype.registerGlobalRenderer = function (t) {
            this.globalRenderers.push(t);
          }),
          (t.prototype.unregisterGlobalRenderer = function () {
            for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
            for (var i = [], n = 0, r = t; n < r.length; n++) {
              var s = r[n];
              s.renderer.markedDelete = !0;
            }
            for (var o = 0, a = this.globalRenderers; o < a.length; o++) {
              s = a[o];
              s.renderer.markedDelete || i.push(s);
            }
            for (var h = 0, c = t; h < c.length; h++) {
              s = c[h];
              delete s.renderer.markedDelete;
            }
            this.globalRenderers = i;
          }),
          (t.prototype.getEffectRenderers = function () {
            return this.effectRenderers.slice(0);
          }),
          (t.prototype.getBackgroundRenderers = function () {
            return this.effectRenderers.slice(0);
          }),
          (t.prototype.setEffectRenderers = function (t) {
            this.effectRenderers = t;
          }),
          (t.prototype.setBackgroundRenderers = function (t) {
            this.backgroundRenderers = t;
          }),
          (t.prototype.setGlobalRenderers = function (t) {
            this.globalRenderers = t;
          }),
          (t.prototype.renderImage = function () {
            if (
              (this._renderImageId &&
                (cancelAnimationFrame(this._renderImageId), delete this._renderImageId),
              !this.source)
            )
              throw new Error("还未导入图片");
            var t = this.source,
              e = this.renderOptions.renderSize,
              i = this.renderOptions.imageBounding,
              n = this.getBackgroundRenderResult({ width: e.width, height: e.height }),
              s = r(n),
              o = this.getEffectRenderOffset(),
              a = this.getEffectRenderResult().canvas;
            s.drawImage(a, 0, 0);
            for (var h = 0, c = this.globalRenderers; h < c.length; h++) {
              var l = c[h];
              n = l.renderer(t, n, v(v({}, o), { width: i.width, height: i.height }));
            }
            this.markInstanceDirty(n), this.requestUpdateView();
          }),
          (t.prototype.requestRenderImage = function () {
            var t = this;
            this._renderImageId ||
              (this._renderImageId = requestAnimationFrame(function () {
                t.renderImage();
              }));
          }),
          (t.prototype.getEffectRenderOffset = function () {
            var t = { top: 0, left: 0, bottom: 0, right: 0 };
            if (!this.renderOptions.fullEffect) return t;
            var e = this.effectRenderers,
              i = {};
            return (
              e.reduce(function (t, e) {
                return e.offset && Object.assign(t, e.offset()), t;
              }, i),
              f(i)
            );
          }),
          (t.prototype.getEffectRenderSize = function () {
            if (!this.source) throw new Error("还未导入图片！");
            var t = this.getEffectRenderOffset();
            return {
              width: this.source.width + t.left + t.right,
              height: this.source.height + t.top + t.bottom,
            };
          }),
          (t.prototype.getBackgroundRenderResult = function (t) {
            if (!this.source) throw new Error("还未导入图片!");
            for (
              var e = s(t.width, t.height).canvas,
                i = this.source,
                n = 0,
                r = this.backgroundRenderers;
              n < r.length;
              n++
            ) {
              var o = r[n];
              o.renderer(i, e);
            }
            return e;
          }),
          (t.prototype.getEffectRenderResult = function () {
            if (!this.source) throw new Error("还未导入图片!");
            var t = this.source;
            if (this.mask) {
              var e = s(this.source.width, this.source.height),
                i = e.canvas,
                n = e.ctx;
              (n.globalCompositeOperation = "copy"),
                n.drawImage(this.source, 0, 0),
                (n.globalCompositeOperation = "destination-in"),
                n.drawImage(this.mask, 0, 0),
                (t = i);
            }
            var r = this.getEffectRenderOffset(),
              o = r.left,
              a = r.top,
              h = r.right,
              c = r.bottom,
              l = this.renderOptions.renderSize,
              u = l.width,
              f = l.height,
              d = this.renderOptions.imageBounding,
              g = d.left,
              p = d.top,
              m = d.width,
              v = d.height;
            (u += o + h), (f += a + c);
            var _ = s(u, f),
              y = _.canvas,
              b = _.ctx;
            if (this.renderOptions.rotate && !this.renderOptions.fullEffect) {
              var x = [g + m / 2, p + v / 2],
                C = x[0],
                w = x[1];
              b.translate(C, w),
                b.rotate((Math.PI / 180) * this.renderOptions.rotate),
                b.translate(-C, -w);
            }
            b.drawImage(t, g + o, p + a, m, v);
            var S = s(u, f),
              T = S.canvas,
              O = S.ctx,
              k = s(u, f),
              E = k.canvas,
              P = k.ctx;
            O.drawImage(y, 0, 0), P.drawImage(T, 0, 0);
            for (var D = 0, j = this.effectRenderers; D < j.length; D++) {
              var A = j[D];
              E = A.renderer(T, E);
            }
            return { canvas: E, offset: r };
          }),
          (t.prototype._isObjTransparent = function (t, e, i) {
            void 0 === i && (i = this.ctx.targetFindTolerance);
            var r = t.canvas,
              s = r.contextCache,
              o = t.selectionBackgroundColor,
              a = r.viewportTransform;
            return (
              (t.selectionBackgroundColor = ""),
              r.clearContext(s),
              s.save(),
              t.render(s, a.slice(0)),
              s.restore(),
              (t.selectionBackgroundColor = o),
              n["fabric"].util.isTransparent(s, e.x, e.y, i)
            );
          }),
          (t.prototype.containsPoint = function (t, e, i) {
            return (
              void 0 === i && (i = this.ctx.targetFindTolerance),
              e instanceof Event && (e = this.toCanvasCoord(e, !0)),
              t.perPixelTargetFind
                ? this._isObjTransparent(t, e, i)
                : t.containsPoint(e, null, !1, !1, i)
            );
          }),
          (t.prototype.markInstanceDirty = function (t) {
            if (!this.instance) throw Error("还未导入图片");
            var e = this.instance;
            t ? ((this.rendered = t), e.setElement(t)) : (t = this.rendered),
              (e.width = t.width),
              (e.height = t.height),
              e.setCoords(),
              (e.dirty = !0);
          }),
          (t.prototype.requestUpdateView = function () {
            this.ctx.requestRenderAll();
          }),
          (t.prototype.updateView = function () {
            this.ctx.renderAll();
          }),
          t
        );
      })();
    },
    1575: function (t, e, i) {
      "use strict";
      var n = function () {
          var t = this,
            e = t.$createElement,
            i = t._self._c || e;
          return i(
            "div",
            { staticClass: "editor-head" },
            [
              i(
                "a",
                { staticClass: "home-link", attrs: { href: "/koutu", target: "_blank" } },
                [i("Icon2", { staticClass: "home-icon", attrs: { name: "home" } })],
                1
              ),
              i("div", { staticClass: "editor-head__gap" }),
              i(
                "div",
                { staticClass: "editor-head__title" },
                [t.$slots.title ? t._t("title") : i("span", [t._v(t._s(t.title))])],
                2
              ),
              i("div", { staticClass: "editor-head__placeholder" }, [t._t("main")], 2),
              t.$slots.btns
                ? t._t("default")
                : [
                    i(
                      "Button",
                      {
                        staticClass: "editor-head__btns editor-head__btns__upload",
                        attrs: { disabled: t.disabled },
                      },
                      [
                        i(
                          "ImagePicker",
                          {
                            ref: "headerUpload",
                            attrs: {
                              multiple: t.multiple,
                              validate: t.validate,
                              disabled: t.disabled,
                              autoOrientation: t.autoOrientation,
                            },
                            on: {
                              change: function (e) {
                                return t.$emit("onUpload", e);
                              },
                              onDisabled: function (e) {
                                return t.$emit("onUploadDisabled");
                              },
                              error: t.handleError,
                            },
                          },
                          [
                            i("Icon2", { attrs: { name: "upload" } }),
                            t._v("\n                " + t._s(t.uploadBtnTxt) + "\n            "),
                          ],
                          1
                        ),
                      ],
                      1
                    ),
                    i(
                      "Button",
                      {
                        staticClass: "editor-head__btns",
                        attrs: { type: "primary" },
                        nativeOn: {
                          click: function (e) {
                            return t.$emit("onDownload");
                          },
                        },
                      },
                      [
                        i("Icon2", { attrs: { name: "download", fill: "white" } }),
                        t._v("\n            " + t._s(t.downloadBtnTxt) + "\n        "),
                      ],
                      1
                    ),
                  ],
            ],
            2
          );
        },
        r = [],
        s = i(20),
        o = {
          components: { Button: s["Button"], ImagePicker: s["ImagePicker"], Icon2: s["Icon2"] },
          props: {
            title: { type: String, default: "" },
            uploadBtnTxt: { type: String, default: "上传" },
            downloadBtnTxt: { type: String, default: "下载" },
            validate: { type: Function, default: () => !0 },
            multiple: { type: Boolean, default: !1 },
            disabled: { type: Boolean, default: !1 },
            autoOrientation: { type: Boolean, default: !0 },
          },
          methods: {
            showFileDialog() {
              this.$refs.headerUpload.showFileDialog();
            },
            handleError(t) {
              this.$error(t.message), this.$emit("error", t);
            },
          },
        },
        a = o,
        h = (i(1540), i(0)),
        c = Object(h["a"])(a, n, r, !1, null, null, null);
      e["a"] = c.exports;
    },
    1578: function (t, e, i) {
      "use strict";
      var n = function () {
          var t = this,
            e = t.$createElement,
            i = t._self._c || e;
          return i("div", { class: [t.bem({ checked: t.state, disabled: t.disabled })] }, [
            i("input", {
              class: t.bem("input"),
              attrs: {
                type: "checkbox",
                id: t.id,
                name: t.name,
                required: t.required,
                disabled: t.disabled,
              },
              domProps: { value: t.value, checked: t.state },
              on: { change: t.onChange },
            }),
            i(
              "label",
              { class: t.bem("label"), attrs: { for: t.id } },
              [
                t._t("input-box", function () {
                  return [
                    i(
                      "span",
                      { class: t.bem("input-box") },
                      [t.state ? i("Icon", { attrs: { name: "check" } }) : t._e()],
                      1
                    ),
                  ];
                }),
                t._t("default"),
              ],
              2
            ),
          ]);
        },
        r = [],
        s = i(130),
        o = i(14),
        a = {
          name: Object(o["b"])("checkout"),
          components: { Icon: s["a"] },
          mixins: [o["a"]],
          model: { prop: "modelValue", event: "input" },
          props: {
            id: {
              type: String,
              default: function () {
                return "checkout-id-" + this._uid;
              },
            },
            name: { type: String, default: null },
            value: { type: [Boolean, Array, Object, String, Number], default: null },
            checked: { type: Boolean, default: !1 },
            modelValue: { type: [Array, Boolean] },
            required: { type: Boolean, default: !1 },
            disabled: { type: Boolean, default: !1 },
          },
          computed: {
            state: function () {
              return void 0 === this.modelValue
                ? this.checked
                : Array.isArray(this.modelValue)
                ? this.modelValue.indexOf(this.value) > -1
                : !!this.modelValue;
            },
          },
          watch: {
            checked: function (t) {
              t !== this.state && this.toggle();
            },
          },
          mounted: function () {
            this.checked && !this.state && this.toggle();
          },
          methods: {
            onChange: function () {
              this.toggle();
            },
            toggle: function () {
              var t;
              Array.isArray(this.modelValue)
                ? ((t = this.modelValue.slice(0)),
                  this.state ? t.splice(t.indexOf(this.value), 1) : t.push(this.value))
                : (t = !this.state),
                this.$emit("input", t);
            },
          },
        },
        h = a,
        c = (i(1542), i(0)),
        l = Object(c["a"])(h, n, r, !1, null, null, null);
      e["a"] = l.exports;
    },
    1659: function (t, e, i) {},
    1660: function (t, e, i) {},
    1661: function (t, e, i) {},
    1978: function (t, e, i) {
      "use strict";
      i.d(e, "a", function () {
        return r;
      });
      var n = i(1475);
      function r(t, e) {
        var i = t instanceof HTMLImageElement ? t.naturalWidth : t.width,
          r = t instanceof HTMLImageElement ? t.naturalHeight : t.height,
          s = Object(n["a"])(i, r),
          o = s.canvas,
          a = s.ctx;
        return (
          a.drawImage(t, 0, 0),
          (a.globalCompositeOperation = "destination-in"),
          a.drawImage(e, 0, 0),
          o
        );
      }
    },
    1979: function (t, e, i) {
      "use strict";
      i.d(e, "a", function () {
        return r;
      });
      var n = i(1541);
      function r(t, e, i) {
        var r = t.getContext("2d"),
          s = t.width,
          o = t.height,
          a = e.width,
          h = e.height,
          c = 0,
          l = 0,
          u = { cover: n["b"], contain: n["a"] }[i],
          f = u(a, h, s, o),
          d = f[0],
          g = f[1];
        return (c = (s - d) / 2), (l = (o - g) / 2), r.drawImage(e, 0, 0, a, h, c, l, d, g), t;
      }
    },
    1981: function (t, e, i) {
      "use strict";
      i(1659);
    },
    1982: function (t, e, i) {
      "use strict";
      i(1660);
    },
    1983: function (t, e, i) {
      t.exports = i.p + "image/watermark_875c4a11.svg";
    },
    1984: function (t, e, i) {
      "use strict";
      i(1661);
    },
    2198: function (t, e, i) {
      "use strict";
      i.r(e);
      var n = function () {
          var t = this,
            e = t.$createElement,
            i = t._self._c || e;
          return i(
            "div",
            { staticClass: "passport" },
            [
              i("EditorHeader", {
                ref: "header",
                attrs: { title: "稿定证件照", uploadBtnTxt: "重新上传" },
                on: { onUpload: t.clickUpload, onDownload: t.download },
              }),
              i(
                "div",
                { staticClass: "passport__editor" },
                [
                  i("FuncPanel", {
                    ref: "func",
                    on: {
                      onSizeChange: t.onSizeChange,
                      onBackgroundChange: t.onBackgroundChange,
                      onFacialAdjustChange: t.onFacialAdjustChange,
                    },
                  }),
                  i(
                    "div",
                    { ref: "container", staticClass: "passport__lego" },
                    [
                      i("ZoomPanel", {
                        attrs: { zoom: t.zoom, tools: { pan: !1 } },
                        on: { onZoomChange: t.setZoom, onFitImage: t.fitImage },
                      }),
                    ],
                    1
                  ),
                ],
                1
              ),
              i("LoadingDialog", {
                attrs: {
                  show: t.uploadProgress.show,
                  progress: t.uploadProgress.progress,
                  title: t.uploadProgress.title,
                },
              }),
              i("BalanceValidation", { ref: "balance" }),
              t.loading
                ? i(
                    "div",
                    {
                      staticClass: "g-dialog__wrapper passport-loading",
                      on: {
                        click: function (e) {
                          return t.$message("请等候处理完成。若长时间无反应，请刷新再试。");
                        },
                      },
                    },
                    [i("Loading", [t._v("生成中")])],
                    1
                  )
                : t._e(),
              i("HelpBtn", {
                attrs: { helpArticle: t.helpArticle },
                on: { "customer-service": t.showUdesk },
              }),
            ],
            1
          );
        },
        r = [],
        s = i(74),
        o = i(1575),
        a = function () {
          var t = this,
            e = t.$createElement,
            i = t._self._c || e;
          return i("div", { staticClass: "passport-func" }, [
            i(
              "div",
              {
                staticClass: "passport-func__section",
                class: 0 === t.activeSection && "passport-func__section--active",
              },
              [
                i("VNode", { attrs: { content: t.genTitleEle("证件类型", 0) } }),
                i(
                  "div",
                  { staticClass: "passport-func__content passport-func__sizes" },
                  [
                    i(
                      "div",
                      {
                        staticClass: "passport-func__size",
                        class: -1 === t.activeSize && "passport-func__size--active",
                        on: {
                          click: function (e) {
                            return t.setSize(-1);
                          },
                        },
                      },
                      [
                        i("Icon2", { attrs: { name: "crop-original" } }),
                        i("div", [t._v("原尺寸")]),
                      ],
                      1
                    ),
                    t._l(t.sizes.slice(0, -1), function (e, n) {
                      return i(
                        "div",
                        {
                          key: "sizes" + n,
                          staticClass: "passport-func__size",
                          class: t.activeSize === n && "passport-func__size--active",
                          on: {
                            click: function (e) {
                              return t.setSize(n);
                            },
                          },
                        },
                        [i("p", [t._v(t._s(e.title))]), i("div", [t._v(t._s(e.subtitle))])]
                      );
                    }),
                  ],
                  2
                ),
                i("div", { staticClass: "passport-func__size__idcard" }, [
                  i(
                    "div",
                    {
                      staticClass: "passport-func__size",
                      class: 6 === t.activeSize && "passport-func__size--active",
                      on: {
                        click: function (e) {
                          return t.setSize(6);
                        },
                      },
                    },
                    [
                      i("p", [t._v(t._s(t.sizes[6].title))]),
                      i("div", [t._v(t._s(t.sizes[6].subtitle))]),
                    ]
                  ),
                ]),
              ],
              1
            ),
            i(
              "div",
              {
                staticClass: "passport-func__section",
                class: 1 === t.activeSection && "passport-func__section--active",
              },
              [
                i("VNode", { attrs: { content: t.genTitleEle("换背景", 1) } }),
                i("div", { staticClass: "passport-func__content passport-func__background" }, [
                  i(
                    "div",
                    [
                      i("VNode", {
                        staticClass: "passport-func__bg--white",
                        attrs: { content: t.genBgEle("#FFF", "白") },
                      }),
                      t._l(t.backgrounds[0], function (e, n) {
                        return i("VNode", {
                          key: "bgline1" + n,
                          attrs: { content: t.genBgEle(e.bg, e.name) },
                        });
                      }),
                      i("VNode", {
                        staticClass: "passport-func__bg--transparent",
                        attrs: { content: t.genBgEle("transparent", "透明") },
                      }),
                      i("div"),
                      i("div"),
                      t._l(t.backgrounds[1], function (e, n) {
                        return i("VNode", {
                          key: "bgline2" + n,
                          attrs: { content: t.genBgEle(e.bg, e.name, e.src) },
                        });
                      }),
                    ],
                    2
                  ),
                ]),
              ],
              1
            ),
            i(
              "div",
              {
                staticClass: "passport-func__section",
                class: 2 === t.activeSection && "passport-func__section--active",
              },
              [
                i("VNode", { attrs: { content: t.genTitleEle("智能调色", 2) } }),
                i(
                  "div",
                  { staticClass: "passport-func__content" },
                  [
                    i(
                      "Checkbox",
                      {
                        on: { input: t.setFacialAdjustment },
                        model: {
                          value: t.facialAdjustment,
                          callback: function (e) {
                            t.facialAdjustment = e;
                          },
                          expression: "facialAdjustment",
                        },
                      },
                      [t._v("\n                自动调整面部光线\n            ")]
                    ),
                  ],
                  1
                ),
              ],
              1
            ),
          ]);
        },
        h = [],
        c = i(1578),
        l = i(237),
        u = i(20),
        f = {
          components: { VNode: l["a"], Icon2: u["Icon2"], Checkbox: c["a"] },
          data() {
            return {
              activeSection: 1,
              activeSize: -1,
              activeBackground: "",
              facialAdjustment: !1,
              // TODO 尺寸
              sizes: [
                { title: "小一寸", subtitle: "22x32mm", val: [259, 377, 18, 111, 0.65] },
                { title: "一寸", subtitle: "25x35mm", val: [295, 413, 27, 129, 0.62] },
                { title: "大一寸", subtitle: "33x48mm", val: [389, 566, 34, 169, 0.64] },
                { title: "小二寸", subtitle: "35x45mm", val: [413, 531, 44, 124, 0.66] },
                { title: "二寸", subtitle: "35x49mm", val: [413, 579, 49, 162, 0.64] },
                { title: "大二寸", subtitle: "35x53mm", val: [413, 626, 50, 202, 0.6] },
                { title: "自定义尺寸", subtitle: "480x640", val: [480, 640, 50, 202, 0.6] },
                { title: "居民身份证", subtitle: "26x32mm", val: [358, 441, 16, 101, 0.73] },
                /**
                 * val 各个参数含义
                 * val[0]: 图片宽度
                 * val[1]: 图片高度
                 * val[2]: 距离顶部距离
                 * val[3]: 未知
                 * val[4]: 缩放比例，0.6挺好
                 */
              ],
              // TODO 背景色
              backgrounds: [
                [
                  { name: "自定义蓝", bg: "#64c5ff" },
                  { name: "浅灰", bg: "#E1E0E5" },
                  { name: "深红", bg: "#C80002" },
                  { name: "红", bg: "#FF0000" },
                  { name: "钴蓝", bg: "#004B73" },
                  { name: "靛青", bg: "#338FB2" },
                  { name: "蓝", bg: "#046BFF" },
                  { name: "天蓝", bg: "#448EDB" },
                  { name: "青蓝", bg: "#00BFF3" },
                ],
                [
                  {
                    name: "绅士红",
                    bg: ["#870D1E", "#CC2D37"],
                    src: "https://st-gdx.dancf.com/assets/20191225-095636-3924.jpg",
                  },
                  {
                    name: "甜蜜粉",
                    bg: ["#E1848D", "#F4A4AC"],
                    src: "https://st-gdx.dancf.com/assets/20191225-095842-e6cf.jpg",
                  },
                  {
                    name: "海马蓝",
                    bg: ["#4A74A9", "#9ABEF0"],
                    src: "https://st-gdx.dancf.com/assets/20191225-095805-9ebe.jpg",
                  },
                  {
                    name: "渐变蓝",
                    bg: ["#379ADC", "#BDE3FF"],
                    src: "https://st-gdx.dancf.com/assets/20191225-095824-ad3a.jpg",
                  },
                  {
                    name: "文艺灰",
                    bg: ["#72798A", "#B5BCCF"],
                    src: "https://st-gdx.dancf.com/assets/20191225-095718-dffe.jpg",
                  },
                  {
                    name: "暖光黄",
                    bg: ["#E1C2A3", "#FCE6D3"],
                    src: "https://st-gdx.dancf.com/assets/20191225-095900-b66a.jpg",
                  },
                ],
              ],
            };
          },
          computed: {
            genTitleEle() {
              const t = this.$createElement;
              return (e, i) =>
                t(
                  "div",
                  { class: "passport-func__title", on: { click: () => this.selectSection(i) } },
                  [e, t(u["Icon2"], { attrs: { name: "right-arrow" } })]
                );
            },
            genBgEle() {
              const t = this.$createElement;
              return (e, i, n) =>
                t(
                  "div",
                  {
                    class: [
                      "passport-func__bg",
                      this.isBgSelected(n || e) && "passport-func__bg--active",
                    ],
                    on: { click: () => this.setBackground(n || e, !0, i) },
                  },
                  [t("div", { style: { background: this.genBgStyle(e) } }), t("p", [i])]
                );
            },
            genBgStyle() {
              return t =>
                "transparent" === t
                  ? ""
                  : "string" === typeof t
                  ? t
                  : `linear-gradient(${t[0]}, ${t[1]})`;
            },
            isBgSelected() {
              return t => t === this.activeBackground;
            },
          },
          methods: {
            selectSection(t) {
              this.activeSection = this.activeSection === t ? -1 : t;
            },
            setBackground(t, e, i) {
              this.activeBackground !== t &&
                ((this.activeBackground = t), e && this.emitBackground(i));
            },
            setSize(t, e = !0) {
              if ("number" === typeof t)
                t !== this.activeSize && ((this.activeSize = t), this.emitSize(e));
              else if (Array.isArray(t)) {
                const [i, n] = t;
                (this.activeSize = this.sizes.findIndex(({ val: t }) => t[0] === i && t[1] === n)),
                  this.emitSize(e);
              }
            },
            emitBackground(t) {
              const e = {
                color: null,
                image: null,
                position: ["center", "center"],
                size: "cover",
                repeat: "no-repeat",
              };
              this.activeBackground &&
                (/http/.test(this.activeBackground)
                  ? (e.image = this.activeBackground)
                  : (e.color = this.activeBackground)),
                this.$emit("onBackgroundChange", e, t);
            },
            emitSize(t) {
              this.$emit("onSizeChange", this.sizes[this.activeSize], t);
            },
            setFacialAdjustment(t, e = !0) {
              (this.facialAdjustment = t), e && this.$emit("onFacialAdjustChange", t, e);
            },
            getActiveInfo() {
              const t = { bg_colour: "透明", id_card_type: "原图" };
              if (/http/.test(this.activeBackground)) {
                const e = this.backgrounds[1].filter(t => t.src === this.activeBackground)[0] || {};
                e.name && (t.bg_colour = e.name);
              } else {
                const e = this.backgrounds[0].filter(t => t.bg === this.activeBackground)[0] || {};
                e.name && (t.bg_colour = e.name);
              }
              const e = this.sizes[this.activeSize];
              return (
                (t.id_card_type = e ? e.title : "原图"), (t.shadow_face = this.facialAdjustment), t
              );
            },
          },
        },
        d = f,
        g = (i(1981), i(0)),
        p = Object(g["a"])(d, a, h, !1, null, null, null),
        m = p.exports,
        v = i(178),
        _ = function () {
          var t = this,
            e = t.$createElement,
            i = t._self._c || e;
          return i(
            "div",
            { staticClass: "zoom-panel" },
            [
              t.defaultTools.pan
                ? i(
                    "Tooltip",
                    { attrs: { placement: "top" } },
                    [
                      i("span", { attrs: { slot: "content" }, slot: "content" }, [t._v("抓手")]),
                      i("Icon", {
                        staticClass: "zoom-panel__pan-icon",
                        attrs: { name: "pan-active", "hover-name": "pan" },
                        nativeOn: {
                          click: function (e) {
                            return t.$emit("onUsePan");
                          },
                        },
                      }),
                    ],
                    1
                  )
                : t._e(),
              t.defaultTools.zoomOut
                ? i(
                    "Tooltip",
                    { attrs: { placement: "top" } },
                    [
                      i("span", { attrs: { slot: "content" }, slot: "content" }, [t._v("缩小")]),
                      i("Icon", {
                        attrs: { name: "zoomout-active", "hover-name": "zoomout" },
                        nativeOn: {
                          click: function (e) {
                            return t.setZoom("out");
                          },
                        },
                      }),
                    ],
                    1
                  )
                : t._e(),
              t.defaultTools.zoomLevel
                ? i(
                    "div",
                    { staticClass: "zoom-panel__level", on: { click: t.fitOrActualSize } },
                    [
                      i("span", { staticClass: "static" }, [
                        t._v(t._s(Math.floor(100 * t.zoom)) + "%"),
                      ]),
                      1 === t.zoom ? i("Icon", { attrs: { name: "fit-image hover" } }) : t._e(),
                      1 !== t.zoom ? i("Icon", { attrs: { name: "real-size hover" } }) : t._e(),
                    ],
                    1
                  )
                : t._e(),
              t.defaultTools.zoomIn
                ? i(
                    "Tooltip",
                    { attrs: { placement: "top" } },
                    [
                      i("span", { attrs: { slot: "content" }, slot: "content" }, [t._v("放大")]),
                      i("Icon", {
                        attrs: { name: "zoomin-active", "hover-name": "zoomin" },
                        nativeOn: {
                          click: function (e) {
                            return t.setZoom("in");
                          },
                        },
                      }),
                    ],
                    1
                  )
                : t._e(),
            ],
            1
          );
        },
        y = [],
        b = i(643),
        x = {
          components: { Tooltip: b["a"], Icon: u["Icon"] },
          props: {
            zoom: { type: Number, required: !0 },
            tools: { type: Object, default: () => ({}) },
          },
          data() {
            return {
              defaultTools: { pan: !0, zoomOut: !0, zoomIn: !0, zoomLevel: !0 },
              zoomLevels: [0.15, 0.2, 0.3, 0.5, 0.8, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, 9, 10],
            };
          },
          created() {
            this.defaultTools = Object.assign(this.defaultTools, this.tools);
          },
          methods: {
            setZoom(t) {
              let e = this.zoomLevels.findIndex(t => this.zoom <= t);
              const { length: i } = this.zoomLevels,
                n = "out" === t;
              if (-1 !== e) {
                if (n) {
                  if (0 === e) return;
                  e--;
                } else {
                  if (e === i - 1) return;
                  e++;
                }
                this.$emit("onZoomChange", this.zoomLevels[e]);
              } else this.$emit("onZoomChange", this.zoomLevels[i - 1]);
            },
            fitOrActualSize() {
              1 === this.zoom ? this.$emit("onFitImage") : this.$emit("onZoomChange", 1);
            },
          },
        },
        C = x,
        w = (i(1982), Object(g["a"])(C, _, y, !1, null, null, null)),
        S = w.exports,
        T = i(113),
        O = i(1426);
      const k = "?x-oss-process=image";
      function E(t) {
        return -1 !== t.indexOf(k);
      }
      function P(t, e) {
        return E(t) ? `${t}${e}` : `${t}${k}${e}`;
      }
      function D(t) {
        return !t || 0 === t.indexOf("data:image/png;base64");
      }
      function j(t, e, i, n = !1) {
        if (D(t)) return t;
        const r = window.devicePixelRatio || 1,
          s = n ? 1 : r;
        let o = "/resize";
        return (
          e && (o += ",w_" + Math.round(e * s)),
          i && (o += ",h_" + Math.round(i * s)),
          (o += ",type_6/interlace,1"),
          P(t, o)
        );
      }
      var A = i(25),
        M = i(1475),
        I = i(1521),
        F = i(1979),
        R = i(1978),
        L = i(1543),
        B = i(1573),
        z = i(1417),
        X = i(1425);
      const Y = function (t, e) {
          const i = new z["fabric"].Line(t, e);
          return (
            (i._render = function (t, e) {
              if (
                (t.beginPath(),
                (!this.strokeDashArray || this.strokeDashArray) &&
                  z["fabric"].StaticCanvas.supports("setLineDash"))
              ) {
                const { x1: i, y1: n, x2: r, y2: s } = this.calcLinePoints(),
                  o = this.width / 2,
                  a = this.height / 2,
                  h = z["fabric"].util.transformPoint({ x: i + o, y: n + a }, e),
                  c = z["fabric"].util.transformPoint({ x: r + o, y: s + a }, e);
                t.moveTo(h.x, h.y), t.lineTo(c.x, c.y);
              }
              t.lineWidth = this.strokeWidth * (this.sizeUniform ? 1 : e[0]);
              const i = t.strokeStyle;
              (t.strokeStyle = this.stroke || t.fillStyle),
                this.stroke && this._renderStroke(t),
                (t.strokeStyle = i);
            }),
            Object(X["a"])(i),
            i
          );
        },
        W = function (t, e) {
          const i = new z["fabric"].Text(t, e);
          return (
            (i._render = function (t, e) {
              const i = e.slice(0),
                n = t.getTransform ? t.getTransform().a : 1,
                r = i[0] * n;
              (i[0] = r),
                (i[3] = r),
                (i[4] = i[4] * n + (this.width / 2) * r),
                (i[5] = i[5] * n + (this.height / 2) * r),
                t.setTransform(...i),
                this._setTextStyles(t),
                this._renderTextLinesBackground(t),
                this._renderTextDecoration(t, "underline"),
                this._renderText(t),
                this._renderTextDecoration(t, "overline"),
                this._renderTextDecoration(t, "linethrough");
            }),
            Object(X["a"])(i),
            i
          );
        };
      var N = i(1983),
        U = i.n(N),
        V = i(1544);
      function H(t, e, i) {
        return (
          e in t
            ? Object.defineProperty(t, e, {
                value: i,
                enumerable: !0,
                configurable: !0,
                writable: !0,
              })
            : (t[e] = i),
          t
        );
      }
      const G = 16,
        q = 4,
        K = 28,
        Z = {
          NO_FACIAL_INFO: "passport.no_facial_info",
          INVALID_SIZE: "passport.invalid_size",
          IMAGE_RENDERED: "passport.image_rendered",
          GET_MASK: "passport.get_mask",
          REPLACE_BACKGROUND: "passport.replace_background",
          FIRST_RENDER: "passport.first_render",
          BEGIN_MATTING: "passport.begin_matting",
          SHADOW_FACE_FAIL: "passport.shadow_face_fail",
          EDITOR_SAVE_START: "passport.editor_save_start",
          EDITOR_SAVE_COMPLETED: "passport.editor_save_completed",
        };
      let $ = [];
      function J(...t) {
        const e = new Y([...t], { stroke: "#D2D8DE", sizeUniform: !0 });
        return $.push(e), e;
      }
      function Q(t, e, i, n = 14) {
        const r = new W(t, { left: e, top: i, fill: "#D2D8DE", fontSize: n });
        return $.push(r), r;
      }
      let tt = 0;
      class et extends B["a"] {
        get facialAdjusted() {
          const { metaInfo: t = {} } = this.content;
          return t.shadowFace;
        }
        constructor(t, e, i) {
          super(t, e, i), H(this, "content", {}), H(this, "id", 0), this.registRenderer();
        }
        emptyRecord(t, e, i, n) {
          return {
            version: "0.0.1",
            sourceImage: t,
            imageHeight: i,
            imageWidth: e,
            featheringRadius: 1,
            lines: [],
            hairLines: [],
            hairDropColors: [],
            hairKeepColors: [],
            pen: [],
            backgroundColor: null,
            recoArea: [],
            recoLines: [],
            scene: null,
            crop: { scale: 1, top: 0, left: 0, width: e, height: i },
            shadow: { offsetX: 0, offsetY: 0, blur: 0, color: "rgba(0,0,0,0)" },
            background: {
              color: "#046BFF",
              image: null,
              position: ["center", "center"],
              size: "cover",
              repeat: "no-repeat",
            },
            outline: [],
            filter: { name: "", strong: 1, url: "", id: 0 },
            filename: n,
            metaInfo: { shadowFace: "" },
          };
        }
        async startMatting(t) {
          const { ctx: e } = Object(M["a"])(),
            i = await Object(V["b"])(U.a),
            n = e.createPattern(i, "repeat");
          this.watermark = n;
          const r = await this.portraitMatting();
          if (!r) return;
          const { background: s, metaInfo: o = {} } = this.content;
          return (
            this._event.emit(Z.REPLACE_BACKGROUND),
            await this.setBackground(s, !1),
            await this.setMetaInfo(o.shadowFace, !1),
            await this.importImage(this.clippedCanvas),
            this._event.emit(Z.FIRST_RENDER),
            t && this.updateRecord(),
            !0
          );
        }
        resetEditor() {
          this.id &&
            ((this.id = 0),
            (this.content = {}),
            delete this.originImage,
            delete this.clippedCanvas,
            delete this.adjustedImage,
            delete this.background,
            delete this.facial);
        }
        async createRecord(t, e, i, n = "") {
          this.resetEditor(), (this.content = this.emptyRecord(t, e, i, n));
          try {
            const t = (
              await A["b"].createMattingRecord({
                content: JSON.stringify(this.content),
                scene: "koutu_pass",
              })
            ).data;
            return (this.id = t.id), await this.drawOriginImage(this.content.sourceImage), !0;
          } catch (r) {
            return console.error(r), Object(T["a"])("创建记录失败，请稍后再试。 " + r.message), !1;
          }
        }
        async getRecord(t) {
          try {
            const e = (await A["b"].getMattingRecord({ id: t })).data;
            return (
              (this.content = JSON.parse(e.content)),
              (this.id = t),
              await this.drawOriginImage(this.content.sourceImage),
              !0
            );
          } catch (e) {
            return !1;
          }
        }
        async portraitMatting() {
          this._event.emit(Z.BEGIN_MATTING);
          let t = "",
            e = "";
          try {
            this.content.scene = "portrait";
            const i = (
              await A["b"].getPortraitMatting({
                id: this.id,
                content: JSON.stringify(this.content),
                use_hair: 1,
                use_face: 1,
                image_mode: 1,
              })
            ).data;
            (t = i.mask_url),
              (e = i.rgb_url),
              (this.resultJpg = e),
              (i.top_index || 0 === i.top_index) &&
                i.face_point &&
                (this.facial = { top: i.top_index, facePoints: i.face_point.split(" ") });
          } catch (i) {
            return Object(T["a"])("人像抠图失败，请稍后再试。 " + i.message), !1;
          }
          try {
            this._event.emit(Z.GET_MASK);
            const { imageWidth: i, imageHeight: n } = this.content,
              r = await Object(I["b"])(t),
              s = await Object(I["b"])(e),
              { canvas: o, ctx: a } = Object(M["a"])(i, n);
            a.drawImage(r, 0, 0);
            const h = a.getImageData(0, 0, i, n);
            return (
              h.data.forEach((t, e) => {
                (e + 1) % 4 === 0 && (h.data[e] = h.data[e - 3]);
              }),
              a.putImageData(h, 0, 0),
              a.save(),
              (a.globalCompositeOperation = "source-in"),
              a.drawImage(s, 0, 0),
              a.restore(),
              (this.originImage = o),
              (this.clippedCanvas = o),
              !0
            );
          } catch (i) {
            return (
              console.error(i), Object(T["a"])("获取抠图信息失败，请稍后再试。 " + i.message), !1
            );
          }
        }
        async drawOriginImage(t) {
          const e = await Object(I["b"])(t),
            { canvas: i, ctx: n } = Object(M["a"])(e.naturalWidth, e.naturalHeight);
          n.drawImage(e, 0, 0), (this.originImage = i);
        }
        registRenderer() {
          this.registerEffectRenderer({ renderer: (t, e) => this.backgroundRender(t, e) }),
            this.registerGlobalRenderer({ renderer: (t, e) => this.watermarkRenderer(t, e) });
        }
        backgroundRender(t, e) {
          const i = Object(M["b"])(e),
            { width: n, height: r } = e,
            { left: s, top: o, width: a, height: h, scale: c } = this.content.crop,
            l = Math.floor(s / c),
            u = Math.floor(o / c),
            f = Math.floor(a / c),
            d = Math.floor(h / c);
          if (this.background) {
            i.save(),
              this.background instanceof HTMLImageElement &&
                Object(F["a"])(e, this.background, "cover");
            const t =
                this.facialAdjusted && this.adjustedImage ? this.adjustedImage : this.originImage,
              s = Object(R["a"])(t, this.clippedCanvas),
              { canvas: o, ctx: a } = Object(M["a"])(f, d);
            return (
              "string" === typeof this.background &&
                ((a.fillStyle = this.background), a.fillRect(0, 0, f, d)),
              a.drawImage(s, -l, -u),
              (i.imageSmoothingEnabled = !0),
              i.drawImage(o, 0, 0, n, r),
              i.restore(),
              e
            );
          }
          return t;
        }
        watermarkRenderer(t, e) {
          if (this.watermark) {
            const t = Object(M["b"])(e);
            t.save(),
              (t.fillStyle = this.watermark),
              t.fillRect(0, 0, e.width, e.height),
              t.restore();
          }
          return e;
        }
        isOriginSize() {
          const { imageWidth: t, imageHeight: e, crop: i } = this.content,
            { left: n, top: r, width: s, height: o, scale: a } = i;
          return t === s && e === o && 0 === n && 0 === r && 1 === a;
        }
        async setSize(t, e = !0) {
          const { imageWidth: i, imageHeight: n } = this.content;
          if (!this.facial) return this._event.emit(Z.NO_FACIAL_INFO), void this.resizeImage(!1);
          if (t.length < 5)
            return (
              (this.content.crop = { left: 0, top: 0, width: i, height: n, scale: 1 }),
              void this.resizeImage(e)
            );
          const [r, s, o, , a] = t,
            { facePoints: h } = this.facial,
            c = this.facial.top,
            l = h[G + 1],
            u = (h[K] - h[q]) / 2 + +h[q],
            f = l - c,
            d = (s - o) / (n - c),
            g = r / 2 / u,
            p = r / 2 / (i - u),
            m = Math.max(d, g, p);
          let v = s / (f / a);
          v < m && (v = m);
          const _ = c * v - o,
            y = u * v - r / 2;
          (this.content.crop = { width: r, height: s, top: _, left: y, scale: v }),
            this.resizeImage(e);
        }
        resizeImage(t = !0) {
          const { imageWidth: e, imageHeight: i } = this.content,
            { width: n, height: r, top: s, left: o, scale: a } = this.content.crop;
          this.setRenderSize({ width: n, height: r }),
            this.setImageRenderBounding({ left: -o, top: -s, width: e * a, height: i * a }),
            this.refreshView(t);
        }
        drawSizeRuler() {
          this.ctx.remove(...$), ($ = []);
          const t = t => t / this.zoom,
            e = Object(M["b"])(this.clippedCanvas),
            i = this.instance.left,
            n = this.instance.top,
            { width: r, height: s } = this.content.crop,
            o = t(52),
            a = n - t(24),
            h = i + r + t(20),
            c = (r - o) / 2,
            l = (s - o) / 2,
            u = t(14),
            f = u / 2,
            d = t(14);
          [
            [0, 0, 0, u],
            [0, f, c, f],
            [r - c, f, r, f],
            [r, 0, r, u],
          ].forEach(([t, e, n, r]) => J(t + i, e + a, n + i, r + a)),
            [
              [0, 0, u, 0],
              [f, 0, f, l],
              [f, s - l, f, s],
              [0, s, u, s],
            ].forEach(([t, e, i, r]) => J(t + h, e + n, i + h, r + n));
          const g = r + "px",
            p = s + "px",
            m = i + c + (o - t(e.measureText(g).width)) / 2,
            v = n + l + (o - e.measureText(p).width) / 2 + 5;
          Q(g, m, a, d), Q(p, h, v, d), this.ctx.add(...$);
        }
        async setBackground(t, e = !0) {
          t.color
            ? (this.background = t.color)
            : t.image
            ? (this.background = await Object(I["b"])(t.image))
            : (this.background = null),
            (this.content.background = t),
            this.refreshView(e);
        }
        refreshView(t = !0) {
          this.source &&
            (cancelAnimationFrame(tt),
            (tt = requestAnimationFrame(() => {
              this.renderImage(),
                this.centerImage(),
                this.fitImage(250),
                this.drawSizeRuler(),
                requestAnimationFrame(() => {
                  this._event.emit(Z.IMAGE_RENDERED), t && this.updateRecord();
                });
            })));
        }
        async updateRecord() {
          try {
            this._event.emit(Z.EDITOR_SAVE_START);
            const t = await Object(L["a"])(this.exportImage().thumb, "image/jpeg", 0.8),
              e = (await Object(O["a"])(t)).url;
            A["b"].updateMattingRecord({
              id: this.id,
              content: JSON.stringify(this.content),
              result_image: e,
              scene: "koutu_pass",
            }),
              this._event.emit(Z.EDITOR_SAVE_COMPLETED);
          } catch (t) {
            console.error(t);
          }
        }
        // TODO 上传图片的尺寸
        exportImage() {
          // 拿目标图片的宽高分别与300做运算
          // 取最大的缩小比例，也即保证图片的宽高都在300以内
          // 将r都替换成e，s都替换成i，即按原图片尺寸上传
          const { canvas: t } = this.getEffectRenderResult(this.content.crop),
            { width: e, height: i } = t,
            n = Math.min(300 / e, 300 / i),
            r = n * e,
            s = n * i,
            { canvas: o, ctx: a } = Object(M["a"])(e, i);
          return (
            (a.fillStyle = "#fff"),
            a.fillRect(0, 0, e, i),
            a.drawImage(t, 0, 0, e, i, 0, 0, e, i),
            { result: t, thumb: o }
          );
        }
        async setMetaInfo(t, e = !0) {
          const { metaInfo: i = {} } = this.content;
          Object.assign(i, { shadowFace: t });
          try {
            if (t && !this.adjustedImage) {
              const { url: t } = (await A["b"].shadowFace({ url: this.resultJpg })).data,
                e = await Object(I["b"])(t);
              this.adjustedImage = Object(V["a"])(e);
            }
          } catch (n) {
            delete i.shadowFace, this._event.emit(Z.SHADOW_FACE_FAIL, n), console.error(n);
          } finally {
            (this.content.metaInfo = i), this.refreshView(e);
          }
        }
      }
      var it = et,
        nt = i(1574),
        rt = i(5);
      function st(t) {
        let e = 0;
        const i = t.length - 1;
        for (let n = 0; n <= i; n++) e += t[n] << (8 * (i - n));
        return e;
      }
      function ot(t, e) {
        const i = [];
        while (t > 0) i.unshift(255 & t), (t >>>= 8);
        if (e) while (i.length < e) i.unshift(0);
        return new Uint8Array(i);
      }
      function at(t) {
        let e = "";
        for (let i = 0, n = t.length; i < n; i++) e += String.fromCharCode(t[i]);
        return e;
      }
      function ht(t) {
        const e = [];
        for (let i = 0; i < t.length; i++) e.push(t[i].charCodeAt(0));
        return new Uint8Array(e);
      }
      function ct(t) {
        return new Promise((e, i) => {
          const n = new FileReader();
          (n.onload = function () {
            e(this.result);
          }),
            (n.onerror = function (t) {
              i(t);
            }),
            n.readAsArrayBuffer(t);
        });
      }
      function lt(t, e, i) {
        return (
          e in t
            ? Object.defineProperty(t, e, {
                value: i,
                enumerable: !0,
                configurable: !0,
                writable: !0,
              })
            : (t[e] = i),
          t
        );
      }
      class ut {
        constructor() {
          lt(this, "crcTable", null);
        }
        createPngDataTable() {
          const t = new Int32Array(256);
          for (let e = 0; e < 256; e++) {
            let i = e;
            for (let t = 0; t < 8; t++) i = 1 & i ? 3988292384 ^ (i >>> 1) : i >>> 1;
            t[e] = i;
          }
          return t;
        }
        calcCrc(t) {
          let e = -1;
          this.crcTable || (this.crcTable = this.createPngDataTable());
          for (let i = 0; i < t.length; i++) e = this.crcTable[255 & (e ^ t[i])] ^ (e >>> 8);
          return -1 ^ e;
        }
        isPNG(t) {
          const e = t.slice(0, 8);
          for (let i = 0; i < e.length; i++) if (e[i] !== ut.PNGHEADER[i]) return !1;
          return !0;
        }
        parseChunks(t, e = {}) {
          const { startAt: i = 8, target: n, result: r = {} } = e,
            s = i + 4,
            o = st(t.slice(i, s)),
            a = s + 4,
            h = at(t.slice(s, a)),
            c = a + o,
            l = t.slice(a, c),
            u = c + 4;
          if (u >= t.length - 12) return r;
          if (!n) {
            if (r[h]) {
              const t = r[h];
              t.length += o;
              const e = new Uint8Array(t.length);
              e.set(t.data), e.set(l, t.data.length), (t.data = e), (t.endAt = u);
            } else r[h] = { name: h, length: o, data: l, startAt: i, endAt: u };
            return this.parseChunks(t, { startAt: u, result: r });
          }
          return n === h
            ? ((r[h] = { name: h, length: o, data: l, startAt: i, endAt: u }), r)
            : this.parseChunks(t, { startAt: u, target: n });
        }
        writePHYS(t, e, i = !1) {
          if (!e) throw Error("请输入需要准确dpi值");
          const { PHYS: n } = ut;
          e *= 39.3701;
          const r = new Uint8Array(21),
            s = ot(9, 4);
          r.set(s);
          const o = ht(n);
          r.set(o, 4);
          const a = ot(e, 4);
          r.set(a, 8), r.set(a, 12), (r[16] = 1);
          const h = this.calcCrc(r.slice(4, 17)),
            c = ot(h);
          r.set(c, 17);
          let l = {};
          if ((i || (l = this.parseChunks(t, { target: n })), l[n])) {
            const e = t.slice(0),
              { startAt: i } = l[n];
            return e.set(r, i), e;
          }
          {
            const e = t.slice(0, 33),
              i = t.slice(33),
              n = new Uint8Array(t.length + r.length);
            return n.set(e), n.set(r, 33), n.set(i, 33 + r.length), n;
          }
        }
      }
      function ft(t, e, i) {
        return (
          e in t
            ? Object.defineProperty(t, e, {
                value: i,
                enumerable: !0,
                configurable: !0,
                writable: !0,
              })
            : (t[e] = i),
          t
        );
      }
      lt(ut, "PNGHEADER", new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10])),
        lt(ut, "PHYS", "pHYs");
      class dt {
        writeDensity(t, e) {
          const i = t.slice(0),
            { DENSITY_UNIT_POS: n, DENSITY_X_POS: r, DENSITY_Y_POS: s } = dt;
          i[n] = 1;
          const o = ot(e, 2);
          return i.set(o, r), i.set(o, s), i;
        }
      }
      ft(dt, "DENSITY_UNIT_POS", 13), ft(dt, "DENSITY_X_POS", 14), ft(dt, "DENSITY_Y_POS", 16);
      const gt = "image/png",
        pt = "image/jpeg",
        mt = new ut(),
        vt = new dt();
      async function _t(t, e = 300) {
        return ct(t).then(i => {
          const n = t.type,
            r = new Uint8Array(i);
          return t.type === pt
            ? new Blob([vt.writeDensity(r, e)], { type: n })
            : n === gt
            ? new Blob([mt.writePHYS(r, e, !0)], { type: n })
            : t;
        });
      }
      var yt = i(23);
      function bt(t, e) {
        var i = Object.keys(t);
        if (Object.getOwnPropertySymbols) {
          var n = Object.getOwnPropertySymbols(t);
          e &&
            (n = n.filter(function (e) {
              return Object.getOwnPropertyDescriptor(t, e).enumerable;
            })),
            i.push.apply(i, n);
        }
        return i;
      }
      function xt(t) {
        for (var e = 1; e < arguments.length; e++) {
          var i = null != arguments[e] ? arguments[e] : {};
          e % 2
            ? bt(Object(i), !0).forEach(function (e) {
                Ct(t, e, i[e]);
              })
            : Object.getOwnPropertyDescriptors
            ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i))
            : bt(Object(i)).forEach(function (e) {
                Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e));
              });
        }
        return t;
      }
      function Ct(t, e, i) {
        return (
          e in t
            ? Object.defineProperty(t, e, {
                value: i,
                enumerable: !0,
                configurable: !0,
                writable: !0,
              })
            : (t[e] = i),
          t
        );
      }
      const wt = "抠图编辑器",
        St = "gd_web",
        Tt = "证件照",
        Ot = Object(yt["a"])({
          download(t) {
            return xt(
              {
                event_id: 31006,
                event: "editor_export_completed",
                editor_type: wt,
                project_name: St,
                load_type: Tt,
                editor_enter_channel: Tt,
              },
              t
            );
          },
          init({ init_elapsed_time: t }) {
            return {
              event_id: 31001,
              event: "editor_init",
              editor_type: wt,
              project_name: St,
              load_type: Tt,
              editor_enter_channel: Tt,
              init_elapsed_time: t,
            };
          },
          editorTemplateLoaded({ load_elapsed_time: t }) {
            return {
              event_id: 31002,
              event: "editor_template_loaded",
              project_name: St,
              editor_type: wt,
              load_elapsed_time: t,
              load_type: Tt,
              editor_enter_channel: Tt,
            };
          },
          editorSaveStart({ work_id: t }) {
            return {
              event_id: 31003,
              event: "editor_save_start",
              project_name: St,
              editor_type: wt,
              load_type: Tt,
              editor_enter_channel: Tt,
              work_id: t,
            };
          },
          editorSaveCompleted({ work_id: t, save_elapsed_time: e }) {
            return {
              event_id: 31004,
              event: "editor_save_completed",
              project_name: St,
              editor_type: wt,
              load_type: Tt,
              editor_enter_channel: Tt,
              work_id: t,
              save_elapsed_time: e,
            };
          },
          editorExportStart({ work_id: t, edit_elapsed_time: e }) {
            return {
              event_id: 31005,
              event: "editor_export_start",
              project_name: St,
              editor_type: wt,
              load_type: Tt,
              editor_enter_channel: Tt,
              work_id: t,
              edit_elapsed_time: e,
            };
          },
          info(t) {
            return xt({ event_id: 2126, event: "id_card_photo_information" }, t);
          },
        });
      var kt = i(1572),
        Et = i(362),
        Pt = i(365);
      let Dt = null;
      function jt() {
        Dt.fitToContainer(), Dt.originImage && Dt.refreshView(!1);
      }
      const At = {};
      var Mt = {
          components: {
            EditorHeader: o["a"],
            FuncPanel: m,
            LoadingDialog: v["a"],
            ZoomPanel: S,
            BalanceValidation: nt["a"],
            Loading: u["Loading"],
            HelpBtn: u["HelpBtn"],
          },
          mixins: [kt["a"], Et["a"]],
          beforeRouteEnter(t, e, i) {
            window._passportPhoto || t.query.id ? i() : i({ path: "/" });
          },
          data() {
            return {
              uploadProgress: { show: !1, progress: 0, title: "上传中" },
              helpArticle: null,
              zoom: 1,
              loading: !1,
              recordLoadTime: 0,
              useType: "",
              useBackground: "",
              useFacialAdjust: "",
              initTime: Date.now(),
            };
          },
          computed: {
            functionUsed() {
              const t = [];
              return (
                [this.useFacialAdjust, this.useType, this.useBackground].forEach(e => {
                  e && t.push(e);
                }),
                t
              );
            },
          },
          async mounted() {
            this.fetchHelpArticle(),
              (Dt = new it(Object(M["a"])().canvas, {
                scrollZoom: !0,
                background: "#ECF0F5",
                centralZoom: !0,
                imageSmoothing: !0,
              })),
              this.$refs.container.appendChild(Dt.el),
              (Dt.el.oncontextmenu = t => t.preventDefault()),
              jt(),
              this.initRecord(),
              (this.zoom = Dt.zoom),
              this.initEvents(),
              window.addEventListener("resize", jt, !1),
              Ot.init({ init_elapsed_time: Date.now() - this.initTime });
          },
          beforeDestroy() {
            window.removeEventListener("resize", jt, !1),
              Object.keys(At).forEach(t => {
                Dt._event.off(t, At[t]);
              }),
              (Dt = null);
          },
          methods: {
            initEvents() {
              (At["editor.zoomed"] = t => (this.zoom = t)),
                (At[Z.NO_FACIAL_INFO] = () => this.openDialog("无法识别人脸", "请重新上传图片。")),
                (At[Z.INVALID_SIZE] = () =>
                  this.openDialog("无法裁剪", "当前图片的尺寸无法满足裁剪要求，请重新上传图片。")),
                (At[Z.IMAGE_RENDERED] = () => (this.loading = !1)),
                (At[Z.BEGIN_MATTING] = () => this.setProgressDialog(45, "开始抠图")),
                (At[Z.GET_MASK] = () => this.setProgressDialog(60, "开始识别人脸")),
                (At[Z.REPLACE_BACKGROUND] = () => this.setProgressDialog(80, "替换背景")),
                (At[Z.FIRST_RENDER] = () => this.setProgressDialog(100, "完成", !1)),
                (At[Z.SHADOW_FACE_FAIL] = t => {
                  this.$refs.func.setFacialAdjustment(!1, !1),
                    Object(T["a"])("智能调色失败。" + t.message);
                });
              let t = Date.now();
              (At[Z.EDITOR_SAVE_START] = () => {
                (t = Date.now()), Ot.editorSaveStart({ work_id: Dt.id });
              }),
                (At[Z.EDITOR_SAVE_COMPLETED] = () => {
                  Ot.editorSaveCompleted({ work_id: Dt.id, save_elapsed_time: Date.now() - t });
                }),
                Object.keys(At).forEach(t => {
                  Dt._event.on(t, At[t]);
                });
            },
            fetchHelpArticle() {
              return A["b"]
                .getArticleWithAlias({ alias: "matting_full" })
                .then(({ data: t }) => {
                  (t.more = "/help/2126"), (this.helpArticle = t);
                })
                .catch(() => {});
            },
            onFacialAdjustChange(t) {
              (this.useFacialAdjust = t ? "智能调色" : ""), (this.loading = !0), Dt.setMetaInfo(t);
            },
            onSizeChange(t, e) {
              (this.useType = null === t || void 0 === t ? void 0 : t.title),
                (this.loading = !0),
                Dt.setSize((null === t || void 0 === t ? void 0 : t.val) || [], e);
            },
            onBackgroundChange(t, e) {
              (this.useBackground = e), Dt.setBackground(t), (this.loading = !0);
            },
            setProgressDialog(t, e, i = !0) {
              this.uploadProgress = { progress: t, title: e, show: i };
            },
            clickUpload(t) {
              Pt["a"].reUpload(), this.createRecord(t);
            },
            async initRecord() {
              const t = Date.now(),
                e = this.$route.query.id;
              e
                ? await this.importRecord(e)
                : window._passportPhoto &&
                  (await this.createRecord(window._passportPhoto), delete window._passportPhoto),
                (this.recordLoadTime = Date.now()),
                Ot.editorTemplateLoaded({ load_elapsed_time: this.recordLoadTime - t });
            },
            async createRecord(t) {
              (this.useFacialAdjust = ""),
                (this.useType = ""),
                (this.useBackground = ""),
                this.setProgressDialog(20, "上传中...");
              const e = t[0];
              let i = "";
              try {
                (i = (await Object(O["a"])(e, { compress: !1 })).url),
                  this.setProgressDialog(30, "上传成功");
              } catch (s) {
                console.log(s),
                  this.setProgressDialog(100, "上传失败"),
                  Object(T["a"])("上传失败，请稍后再试。 " + s.message);
              }
              i = j(i, 2e3, 2e3, !0);
              const n = await Object(I["b"])(i);
              try {
                await Dt.createRecord(i, n.width, n.height, e.name),
                  this.$router.replace("/passport-photo?id=" + Dt.id);
              } catch (s) {
                return (
                  console.log(s),
                  this.setProgressDialog(100, "创建记录失败", !1),
                  void Object(T["a"])("上传失败，请稍后再试。 " + s.message)
                );
              }
              const r = await Dt.startMatting(!0);
              r
                ? (this.syncRecord(), this.setProgressDialog(100, "", !1))
                : this.setProgressDialog(100, "抠图失败...", !1);
            },
            async importRecord(t) {
              try {
                this.setProgressDialog(20, "载入记录中...", !0), await Dt.getRecord(t);
              } catch (i) {
                return void this.setProgressDialog(100, "载入记录失败...", !1);
              }
              const e = await Dt.startMatting();
              e ? this.syncRecord() : this.setProgressDialog(100, "抠图失败...", !1);
            },
            syncRecord() {
              const t = this.$refs.func,
                { background: e, crop: i, metaInfo: n = {} } = Dt.content;
              e && t.setBackground(e.color || e.image || "transparent", !1),
                i && t.setSize([i.width, i.height], !1),
                t.setFacialAdjustment(!!n.shadowFace, !1);
            },
            async download() {
              var t;
              if (!rt["a"].isLogin) return void (await rt["a"].login());
              const { result: e, thumb: i } = Dt.exportImage(),
                n = Dt.id,
                { data: r } = await A["b"].queryMattingInfo({ ids: [n] }),
                s = null !== (t = r[0]) && void 0 !== t && t.download_count ? 0 : 1,
                o = await this.openExportDialog({
                  resultImage: e,
                  customUseCount: s,
                  images: [{ id: n, name: "", image: "", type: "", size: "" }],
                });
              if (!o) return;
              if ("noRight" === o.okType) return void this.$refs.balance.openPricingDialog();
              this.setProgressDialog(50, "下载中...", !0);
              const a = await this.$refs.balance.rightsPassportUse(s);
              if (!a) return void this.exportErrorHandling();
              const h = Date.now() - this.recordLoadTime;
              Ot.editorExportStart({ work_id: Dt.id, edit_elapsed_time: h });
              const { type: c, quality: l } = o,
                u = Date.now();
              try {
                const t = await Object(L["a"])(e, "image/" + c, l),
                  i = await _t(t, 300),
                  n = Dt.content.filename || "稿定";
                this.downloadFiles({
                  file: i,
                  filename: `${n.replace(/\.(jpg|png|jpeg)$/i, "")}-稿定证件照.${c}`,
                }),
                  A["b"].postEmsLogs({ target_id: this.$route.query.id, type: 1 });
              } catch (f) {
                return void this.exportErrorHandling(f);
              }
              this.setProgressDialog(100, "导出成功。", !1),
                Ot.download({
                  work_id: n,
                  export_elapsed_time: Date.now() - u,
                  function_used: this.functionUsed,
                  edit_elapsed_time: h,
                }),
                Ot.info(this.$refs.func.getActiveInfo()),
                Object(O["a"])(await Object(L["a"])(i)).then(t =>
                  this.updateDownload([n]).then(() => {
                    this.updateResultImage([{ id: n, resultImage: t.url }]);
                  })
                );
            },
            exportErrorHandling(t) {
              t && (Object(T["a"])("导出图片失败，请刷新再试。 " + t.message), console.error(t)),
                this.setProgressDialog(100, "导出图片失败，请刷新再试。", !1);
            },
            setZoom(t) {
              const { width: e, height: i } = Dt.ctx;
              Dt.setZoom(t, { x: e / 2, y: i / 2 });
            },
            fitImage() {
              Dt.fitImage(), Dt.updateView();
            },
            openDialog(t, e) {
              return (
                (this.loading = !1),
                s["a"].open({
                  title: t,
                  content: e,
                  okText: "确定",
                  onOk: () => this.$refs.header.showFileDialog(),
                })
              );
            },
          },
        },
        It = Mt,
        Ft = (i(1984), Object(g["a"])(It, n, r, !1, null, null, null));
      e["default"] = Ft.exports;
    },
  },
]);
